<template>
  <div style="height: 100%; width: 100%; position: relative">
    <div class="pagetop">
      <div style="width: 100%">
        <div style="width: 100%; float: left">
          <table class="table1style">
            <tr>
              <td>快速查找</td>
              <td>
                <el-input size="small" style="width: 160px" v-model="sel_strinput" @keyup.enter.native="MainTable_Rfresh"
                  clearable placeholder="用户代号|名称|输入码"></el-input>
              </td>
              <td>用户大类</td>
              <td>
                <el-select v-model="sel_userkind" placeholder="请选择" style="width: 120px" @change="MainTable_Rfresh">
                  <el-option key="" label="所有" value=""></el-option>
                  <el-option key="1" label="检验用户" value="1"></el-option>
                  <el-option key="2" label="临床医生" value="2"></el-option>
                  <el-option key="3" label="临床护士" value="3"></el-option>
                  <el-option key="8" label="护工" value="8"></el-option>
                  <el-option key="9" label="其它用户" value="9"></el-option>
                </el-select>
              </td>
              <td>医生级别</td>
              <td>
                <el-select v-model="sel_doctorkind" placeholder="请选择" style="width: 120px" @change="MainTable_Rfresh">
                  <!-- <el-option key="" label="所有" value=""></el-option>
                                  <el-option key="10" label="普通医生" value="10"></el-option>
                                  <el-option key="20" label="主治医生" value="20"></el-option>
                                  <el-option key="30" label="副主任医生" value="30"></el-option>
                                  <el-option key="40" label="主任医生" value="40"></el-option> -->
                  <el-option v-for="(item, index) in $opt.doctorkindOption" :key="index" :label="item.label"
                    :value="item.value">
                    <span style="float: left">{{ item.label }}</span>
                    <span style="float: right; color: #8492a6; font-size: 13px">{{ item.value }}</span>
                  </el-option>
                </el-select>
              </td>
              <td>主任标志</td>
              <td>
                <el-select v-model="sel_doctormaster" placeholder="请选择" style="width: 120px" @change="MainTable_Rfresh">
                  <el-option key="" label="所有" value=""></el-option>
                  <el-option key="0" label="非主任" value="0"></el-option>
                  <el-option key="1" label="科副主任" value="1"></el-option>
                  <el-option key="2" label="科主任" value="2"></el-option>
                </el-select>
              </td>
              <td>所属科室</td>
              <td>
                <rm-ddl-common @change="deptchange" :clearable="true" datatype="dept" dataname="科室" v-model="deptno"
                  width="140px"></rm-ddl-common>
              </td>
              <td v-show="isRegLis">医院</td>
              <td v-show="isRegLis">
                <rm-ddl-common @change="hospitalChange" datatype="hospital" dataname="医院" v-model="hospitalval"
                  width="180px"></rm-ddl-common>
              </td>
            </tr>
          </table>
        </div>
        <div style="width: 100%; float: left">
          <table style="float: right">
            <tr>
              <td style="align: right">
                <el-button @click="MainTable_Rfresh" icon="el-icon-search" v-has="'PINQUERY'"
                  type="primary">查询</el-button>
              </td>
              <td style="align: right" v-if="tab_showflag == 'tabname_jbxx'">
                <el-button @click="BacthUploadSign">批量上传签名</el-button>
              </td>
              <td style="align: right" v-if="tab_showflag == 'tabname_jbxx'">
                <el-button @click="BtndownloadSign">批量导出签名</el-button>
              </td>
              <td style="align: right">
                <el-button v-if="tab_showflag == 'tabname_jbxx'" @click="tab_jbxx_addEvent(1)" icon="el-icon-plus"
                  v-has="'PADD'" :disabled="changeflag">新增</el-button>
                <el-button v-if="tab_showflag == 'tabname_jbxx'" @click="tab_jbxx_delete" icon="el-icon-delete"
                  v-has="'PDELETE'" :disabled="changeflag">删除</el-button>
                <el-button v-if="tab_showflag == 'tabname_jbxx' || tab_showflag == 'tabname_ip'" @click="tab_jbxx_save"
                  icon="el-icon-document" :disabled="!changeflag">保存</el-button>
                <el-button v-if="tab_showflag == 'tabname_jbxx' || tab_showflag == 'tabname_ip'" @click="tab_jbxx_close"
                  icon="el-icon-close" :disabled="!changeflag">取消</el-button>
                <el-button v-if="tab_showflag == 'tabname_jbxx'" @click="pswmod">密码修改</el-button>
                <el-button v-if="tab_showflag == 'tabname_jbxx'" @click="syncData"
                  icon="el-icon-position">用户同步</el-button>
                <el-button @click="setPrimaryPwd"
                  v-if="loginuser_utype == 'G' && tab_showflag == 'tabname_jbxx'">设置初始密码</el-button>
                <el-button @click="syncsign">同步电子签名</el-button>
                <el-button @click="resetLogindt" v-if="loginuser_utype == 'G' && unlogindays != '0'">账号解禁</el-button>
                <!-- <el-button @click="syncData" icon="el-icon-position" v-if="usersync">用户同步</el-button>
                              <el-button @click="savesyncdata" icon="el-icon-position" v-else>保存同步</el-button> -->
                <!--v-has="'PSYNC'"-->
              </td>
            </tr>
          </table>
        </div>
      </div>
    </div>
    <div class="pagecenter">
      <rm-layout-right splitcolor="white" movingcolor="#00ffff" :splitwidth=5 fixsize="31%">
        <template v-slot:fix>
          <div style="height:100%">
            <el-tabs style="height: 100%" type="border-card" @tab-click="tab_getdata" v-model="tab_showflag">
              <el-tab-pane label="详细信息" name="tabname_jbxx">
                <div style="overflow: auto; height: 100%; width: 100%; position: relative" v-loading="pageinitloading"
                  element-loading-spinner="el-icon-loading" element-loading-background="rgba(0, 0, 0, 0.8)">
                  <el-form :inline="true" @submit.native.prevent label-width="auto" ref="form_jbxx"
                    :disabled="ifCanEditFlag" :model="Tab_jbxx_Data">
                    <table>
                      <tr>
                        <td>
                          <font color="#F56C6C">用户代号</font>
                        </td>
                        <td colspan="3">
                          <el-input size="small" style="width: 180px" v-model="Tab_jbxx_Data.userno"
                            @change="usernochange_event" :disabled="userno_disabled" @input="HasChange"
                            ref="txtusernoid"></el-input>
                        </td>
                        <td>
                          <font color="#F56C6C">是否可用</font>
                        </td>
                        <td colspan="3">
                          <el-radio v-model="Tab_jbxx_Data.enabled" label="1" @change="HasChange">有效</el-radio>
                          <el-radio v-model="Tab_jbxx_Data.enabled" label="0" @change="HasChange">无效</el-radio>
                        </td>
                      </tr>
                      <tr>
                        <td>
                          <font>
                            <font color="#F56C6C">用户名称</font>
                          </font>
                        </td>
                        <td colspan="3">
                          <el-input size="small" style="width: 180px" v-model="Tab_jbxx_Data.username" clearable
                            @input="HasChange" @change="usernamechange_event" ref="txtusernameid"></el-input>
                        </td>
                        <td>
                          <font>
                            <font>英文姓名</font>
                          </font>
                        </td>
                        <td colspan="3">
                          <el-input size="small" style="width: 180px" v-model="Tab_jbxx_Data.usernameen" clearable
                            @input="HasChange" ref="txtusernameenid"></el-input>
                        </td>
                      </tr>
                      <tr>
                        <td>
                          <font color="#F56C6C">用户类型</font>
                        </td>
                        <td colspan="3">
                          <el-select v-model="Tab_jbxx_Data.utype" placeholder="请选择" style="width: 180px"
                            :disabled="loginuser_utype != 'G' && loginuser_utype != 'R'" @change="HasChange">
                            <el-option v-for="(item, index) in utypeOption" :key="index" :value="item.value"
                              :label="item.label"></el-option>
                          </el-select>
                        </td>
                        <!--<td></td>
                                              <td colspan="3"></td> -->
                        <td rowspan="4">用户照片</td>
                        <td colspan="3" rowspan="6">
                          <el-upload class="avatar-uploader" action="" :show-file-list="false" :auto-upload="false"
                            :before-upload="imagebefore" :on-change="photoimagechange" accept="image/jpeg,image/png">
                            <img v-if="PhotoImageUrl" :src="PhotoImageUrl" class="avatar" />
                            <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                          </el-upload>
                        </td>
                      </tr>
                      <!-- <tr>
                                              <td>密码</td>
                                              <td colspan="3">
                                                  <el-input size="small" style="width: 180px" v-model="Tab_jbxx_Data.pwd" clearable type="text" autocomplete="new-password" @change="inputChange($event)" @clear.native="pwdClear(1)" ref="RefPwd1" @input="HasChange"></el-input>
                                                  <el-input size="small" v-model="temppwd1" v-show="false"></el-input>
                                                  <el-input size="small" v-model="temppwd2" v-show="false"></el-input>
                                              </td>
                                              <td></td>
                                              <td colspan="3"></td>
                                          </tr>
                                          <tr>
                                              <td>密码确认</td>
                                              <td colspan="3">
                                                  <el-input size="small" style="width: 180px" v-model="repeat_pwd" clearable type="text" autocomplete="off" @clear.native="pwdClear(2)" @change="inputChange_confirm($event)" ref="RefPwd2" @input="HasChange"></el-input>
                                                  <el-input size="small" v-model="temppwd3" v-show="false"></el-input>
                                              </td>
                                              <td></td>
                                              <td colspan="3"></td>
                                          </tr> -->
                      <tr>
                        <td>用户大类</td>
                        <td colspan="3">
                          <el-select v-model="Tab_jbxx_Data.userkind" placeholder="请选择" style="width: 180px"
                            @change="HasChange">
                            <el-option key="1" label="检验用户" value="1"></el-option>
                            <el-option key="2" label="临床医生" value="2"></el-option>
                            <el-option key="3" label="临床护士" value="3"></el-option>
                            <el-option key="8" label="护工" value="8"></el-option>
                            <el-option key="9" label="其它用户" value="9"></el-option>
                          </el-select>
                        </td>
                        <td></td>
                        <td colspan="3"></td>
                      </tr>
                      <tr>
                        <td>医生级别</td>
                        <td colspan="3">
                          <el-select v-model="Tab_jbxx_Data.doctorkind" placeholder="请选择" style="width: 180px"
                            @change="HasChange">
                            <!-- <el-option key="10" label="普通医生" value="10"></el-option>
                                                      <el-option key="20" label="主治医生" value="20"></el-option>
                                                      <el-option key="30" label="副主任医生" value="30"></el-option>
                                                      <el-option key="40" label="主任医生" value="40"></el-option> -->
                            <el-option v-for="(item, index) in $opt.doctorkindOption" :key="index" :label="item.label"
                              :value="item.value">
                              <span style="float: left">{{ item.label }}</span>
                              <span style="float: right; color: #8492a6; font-size: 13px">{{ item.value }}</span>
                            </el-option>
                          </el-select>
                        </td>
                        <td></td>
                        <td colspan="3"></td>
                      </tr>
                      <tr>
                        <td>主任标志</td>
                        <td colspan="3">
                          <el-select v-model="Tab_jbxx_Data.doctormaster" placeholder="请选择" style="width: 180px"
                            @change="HasChange">
                            <el-option key="0" label="非主任" value="0"></el-option>
                            <el-option key="1" label="科副主任" value="1"></el-option>
                            <el-option key="2" label="科主任" value="2"></el-option>
                          </el-select>
                        </td>
                        <td></td>
                        <td colspan="3"></td>
                      </tr>
                      <tr>
                        <td>默认程序</td>
                        <td colspan="3">
                          <rm_prgList @input="defaultprgChange" v-model="Tab_jbxx_Data.defaultprg"></rm_prgList>
                          <!--这里之前使用:value-->
                          <!--:disabled="Tab_jbxx_Data.hospcode=='All'?true:false"-->
                          <el-input v-model="Tab_jbxx_Data.defaultprg" v-show="false"></el-input>
                        </td>

                        <td></td>
                        <td colspan="3"></td>
                      </tr>
                      <tr>
                        <td>HIS系统对照1</td>
                        <td colspan="3">
                          <el-input size="small" style="width: 180px" v-model="Tab_jbxx_Data.hiscode1" clearable
                            @input="HasChange" @dblclick.native="hiscode1Open" placeholder="双击选择医生代码"></el-input>
                        </td>
                        <td></td>
                        <td colspan="3"></td>
                      </tr>
                      <tr>
                        <td>助记符</td>
                        <td colspan="3">
                          <el-input size="small" style="width: 180px" v-model="Tab_jbxx_Data.inputcode" clearable
                            @input="HasChange"></el-input>
                        </td>

                        <td rowspan="2">电子签名</td>
                        <td colspan="3" rowspan="2">
                          <el-upload class="avatar-uploader" action="" :show-file-list="false" :auto-upload="false"
                            :on-change="signimagechange" :before-upload="imagebefore" accept="image/jpeg,image/png">
                            <img v-if="SignImageUrl" :src="SignImageUrl" class="avatar1" />
                            <i v-else class="el-icon-plus avatar-uploader-icon1"></i>
                          </el-upload>
                        </td>
                      </tr>

                      <tr>
                        <td>病区代码</td>
                        <td colspan="3">
                          <!-- <el-input size="small" style="width:180px;" v-model="Tab_jbxx_Data.wardno" clearable @input="HasChange"></el-input> -->
                          <rm-ddl-common @change="wardnoChange" :clearable="true" datatype="ward" dataname="病区"
                            v-model="Tab_jbxx_Data.wardno" width="180px"></rm-ddl-common>
                        </td>

                      </tr>
                      <tr>
                        <td>科室代码</td>
                        <td colspan="3">
                          <!-- <el-input size="small" style="width:180px;" v-model="Tab_jbxx_Data.deptno" clearable @input="HasChange"></el-input> -->
                          <rm-ddl-common @change="deptnoChange" :clearable="true" datatype="dept" dataname="科室"
                            v-model="Tab_jbxx_Data.deptno" width="180px"></rm-ddl-common>
                        </td>
                        <td>平台认证码</td>
                        <td colspan="3">
                          <el-input size="small" style="width: 180px" v-model="Tab_jbxx_Data.hiscode2" clearable
                            @input="HasChange"></el-input>
                        </td>
                      </tr>

                      <tr>
                        <td>
                          <font>
                            <font color="#F56C6C">所属医院</font>
                          </font>
                        </td>
                        <td colspan="3">
                          <rm-ddl-common datatype="hospital" dataname="医院" v-model="Tab_jbxx_Data.hospcode" width="180px"
                            :disabled="loginuser_utype != 'G' && loginuser_utype != 'R'"
                            @change="hospChange"></rm-ddl-common>
                        </td>
                        <td>CA启用时间</td>
                        <td colspan="3">
                          <el-date-picker v-model="Tab_jbxx_Data.castartdt" type="datetime" placeholder="选择日期时间"
                            style="width: 180px" @change="HasChange" value-format="yyyy-MM-dd HH:mm:ss"
                            format="yyyy-MM-dd HH:mm:ss"> </el-date-picker>
                        </td>
                      </tr>
                      <tr>
                        <td>身份证号</td>
                        <td colspan="7">
                          <el-input size="small" style="width: 445px" v-model="Tab_jbxx_Data.idcardno" clearable
                            @input="HasChange"></el-input>
                        </td>
                      </tr>
                      <tr>
                        <td>备用1</td>
                        <td colspan="7">
                          <el-input size="small" style="width: 445px" v-model="Tab_jbxx_Data.bk1" clearable
                            @input="HasChange"></el-input>
                        </td>
                      </tr>
                      <tr>
                        <td>备用2</td>
                        <td colspan="7">
                          <el-input size="small" style="width: 445px" v-model="Tab_jbxx_Data.bk2" clearable
                            @input="HasChange"></el-input>
                        </td>
                      </tr>
                      <tr>
                        <td>备用3</td>
                        <td colspan="7">
                          <el-input size="small" style="width: 445px" v-model="Tab_jbxx_Data.bk3" clearable
                            @input="HasChange"></el-input>
                        </td>
                      </tr>
                    </table>
                  </el-form>
                </div>
              </el-tab-pane>
              <el-tab-pane label="对应角色" name="tabname_dyjs" :disabled="actionindex == 'A'">
                <div class="middle-tab-bottom">
                  <rm-layout-top splitcolor="white" :splitwidth="5" :fixsize="40" :canDrag="false">
                    <template v-slot:fix>
                      <div style="height: 40px; border: 1px solid #ccc">
                        <table>
                          <tr>
                            <td style="font-weight: 800">未对应角色检索</td>
                            <td>
                              <el-input v-model="searchobj.queryleftrole" placeholder="角色代码|角色名称" style="width: 175px"
                                ref="refqueryleftrole" clearable></el-input>
                            </td>
                          </tr>
                        </table>
                      </div>
                    </template>

                    <div style="height: 100%; width: 100%">
                      <div style="float: left; width: 100%; height: 100%">
                        <div style="float: left; width: calc(50% - 3px); height: 100%">
                          <vxe-table :data.sync="userofrolelist" :select-config="{ reserve: true }"
                            :sort-config="{ trigger: 'cell' }" border height="auto" highlight-current-row
                            highlight-hover-column highlight-hover-row how-header-overflow ref="tab_dyjs_nohaven_table"
                            resizable show-overflow size="mini" stripe show-header-overflow
                            :optimization="{ animat: false }" header-align="center"
                            @cell-dblclick="tab_dyjs_nohavenuser_dbclickEvent">
                            <vxe-table-column field="rolename" sortable title="未对应角色名称" width="120"
                              show-overflow></vxe-table-column>
                            <vxe-table-column field="roleno" sortable title="未对应角色代码" width="120"
                              show-overflow></vxe-table-column>
                          </vxe-table>
                        </div>
                        <div style="float: left; height: 100%; width: calc(50% - 3px); margin-left: 5px">
                          <vxe-table :data.sync="tab_dyjs_havenuser_data" :select-config="{ reserve: true }"
                            :sort-config="{ trigger: 'cell' }" border height="auto" highlight-current-row
                            highlight-hover-column highlight-hover-row how-header-overflow ref="tab_dyjs_haven_table"
                            resizable show-overflow size="mini" stripe show-header-overflow
                            :optimization="{ animat: false }" header-align="center"
                            @cell-dblclick="tab_dyjs_havenuser_dbclickEvent">
                            <vxe-table-column field="rolename" sortable title="已对应角色名称" width="120"
                              show-overflow></vxe-table-column>
                            <vxe-table-column field="roleno" sortable title="已对应角色代码" width="120"
                              show-overflow></vxe-table-column>
                            <vxe-table-column field="rolevaliditydt" sortable title="有效期至" width="120"
                              show-overflow></vxe-table-column>
                          </vxe-table>
                        </div>
                      </div>
                    </div>
                  </rm-layout-top>
                </div>
              </el-tab-pane>
              <el-tab-pane label="对应院区" name="tabname_dyyq" :disabled="actionindex == 'A'">
                <div class="middle-tab-bottom">
                  <rm-layout-top splitcolor="white" :splitwidth="5" :fixsize="40" :canDrag="false">
                    <template v-slot:fix>
                      <div style="height: 40px; border: 1px solid #ccc">
                        <table>
                          <tr>
                            <td style="font-weight: 800">未对应院区检索</td>
                            <td>
                              <el-input v-model="searchobj.querylefthosp" placeholder="院区代码|院区名称" style="width: 150px"
                                ref="refquerylefthosp" clearable></el-input>
                            </td>
                            <td style="font-weight: 800">未对应区域检索</td>
                            <td>
                              <!-- <el-input v-model="searchobj.queryleftregion" placeholder="区域代码|区域名称" style="width: 150px" ref="refqueryleftregion" clearable></el-input>
                                                          -->
                              <rm-ddl-common datatype="region" dataname="区域" v-model="searchobj.queryleftregion"
                                width="150px"></rm-ddl-common>
                            </td>
                          </tr>
                        </table>
                      </div>
                    </template>

                    <div style="height: 100%; width: 100%">
                      <div style="float: left; width: 100%; height: 100%">
                        <div style="float: left; width: calc(50% - 15px); height: 100%">
                          <vxe-table :data.sync="userofhosplist" :select-config="{ reserve: true }"
                            :sort-config="{ trigger: 'cell' }" border height="auto" highlight-current-row
                            highlight-hover-column highlight-hover-row how-header-overflow ref="tab_dyyq_nohaven_table"
                            resizable show-overflow size="mini" stripe show-header-overflow
                            :optimization="{ animat: false }" header-align="center"
                            @cell-dblclick="tab_dyyq_nohavenhosp_dbclickEvent">
                            <vxe-table-column type="selection" width="40" align="center"></vxe-table-column>
                            <vxe-table-column field="hospitalname" sortable title="未对应院区名称" width="100"
                              show-overflow></vxe-table-column>
                            <vxe-table-column field="hospcode" sortable title="未对应院区代码" width="100"
                              show-overflow></vxe-table-column>
                            <vxe-table-column field="regionname" sortable title="未对应区域名称" width="100"
                              show-overflow></vxe-table-column>
                            <vxe-table-column field="regionid" sortable title="未对应区域代码" width="100"
                              show-overflow></vxe-table-column>
                          </vxe-table>
                        </div>
                        <div class="table-deal-btn" style="float: left; width: 20px; height: 100%;">
                          <div class="table-deal-btn-item">
                            <div>
                              <el-button class="el-icon-d-arrow-right" @click="SetMultipleSelect"></el-button>
                            </div>
                            <!-- <div>
                                                          <el-button class="el-icon-d-arrow-left" @click="DelMultipleSelect"></el-button>
                                                      </div> -->
                          </div>
                        </div>
                        <div style="float: right; height: 100%; width: calc(50% - 15px);">
                          <vxe-table :data.sync="tab_dyyq_havenhosp_data" :select-config="{ reserve: true }"
                            :sort-config="{ trigger: 'cell' }" border height="auto" highlight-current-row
                            highlight-hover-column highlight-hover-row how-header-overflow ref="tab_dyyq_haven_table"
                            resizable show-overflow size="mini" stripe show-header-overflow
                            :optimization="{ animat: false }" header-align="center"
                            @cell-dblclick="tab_dyyq_havenhosp_dbclickEvent">
                            <vxe-table-column field="hospitalname" sortable title="已对应院区名称" width="100"
                              show-overflow></vxe-table-column>
                            <vxe-table-column field="hospcode" sortable title="已对应院区代码" width="100"
                              show-overflow></vxe-table-column>
                            <vxe-table-column field="regionname" sortable title="已对应区域名称" width="100"
                              show-overflow></vxe-table-column>
                            <vxe-table-column field="regionid" sortable title="已对应区域代码" width="100"
                              show-overflow></vxe-table-column>
                          </vxe-table>
                        </div>
                      </div>
                    </div>
                  </rm-layout-top>
                </div>
              </el-tab-pane>
              <el-tab-pane label="对应区域" name="tabname_dyqy" :disabled="actionindex == 'A'">
                <div class="middle-tab-bottom">
                  <rm-layout-top splitcolor="white" :splitwidth="5" :fixsize="40" :canDrag="false">
                    <template v-slot:fix>
                      <div style="height: 40px; border: 1px solid #ccc">
                        <table>
                          <tr>
                            <td style="font-weight: 800">未对应区域检索</td>
                            <td>
                              <el-input v-model="searchobj.queryleftreg" placeholder="区域代码|区域名称" style="width: 175px"
                                ref="refqueryleftreg" clearable></el-input>
                            </td>
                          </tr>
                        </table>
                      </div>
                    </template>

                    <div style="height: 100%; width: 100%">
                      <div style="float: left; width: 100%; height: 100%">
                        <div style="float: left; width: calc(50% - 3px); height: 100%">
                          <vxe-table :data.sync="userofreglist" :select-config="{ reserve: true }"
                            :sort-config="{ trigger: 'cell' }" border height="auto" highlight-current-row
                            highlight-hover-column highlight-hover-row how-header-overflow ref="tab_dyyq_nohavenreg_table"
                            resizable show-overflow size="mini" stripe show-header-overflow
                            :optimization="{ animat: false }" header-align="center"
                            @cell-dblclick="tab_dyyq_nohavenreg_dbclickEvent">
                            <vxe-table-column field="regionname" sortable title="未对应区域名称" width="150" show-overflow>
                              <template v-slot="{ row }">
                                <div style="text-indent:2em;font-weight:800" v-if="row.regionlevel == '1'">
                                  {{ row.regionname }}</div>
                                <div style="text-indent:4em;font-weight:400" v-else-if="row.regionlevel == '2'">
                                  {{ row.regionname }}</div>
                                <div v-else-if="row.regionlevel == '3'" style="text-indent:6em;">{{ row.regionname }}</div>
                                <div v-else style="font-weight:bolder">{{ row.regionname }}</div>
                              </template>
                            </vxe-table-column>
                            <vxe-table-column field="regioncode" sortable title="未对应区域代码" width="120"
                              show-overflow></vxe-table-column>
                          </vxe-table>
                        </div>
                        <div style="float: left; height: 100%; width: calc(50% - 3px); margin-left: 5px">
                          <vxe-table :data.sync="tab_dyyq_havenreg_data" :select-config="{ reserve: true }"
                            :sort-config="{ trigger: 'cell' }" border height="auto" highlight-current-row
                            highlight-hover-column highlight-hover-row how-header-overflow ref="tab_dyyq_havenreg_table"
                            resizable show-overflow size="mini" stripe show-header-overflow
                            :optimization="{ animat: false }" header-align="center"
                            @cell-dblclick="tab_dyyq_havenreg_dbclickEvent">
                            <vxe-table-column field="regionname" sortable title="已对应区域名称" width="150"
                              show-overflow></vxe-table-column>
                            <vxe-table-column field="regioncode" sortable title="已对应区域代码" width="120"
                              show-overflow></vxe-table-column>
                          </vxe-table>
                        </div>
                      </div>
                    </div>
                  </rm-layout-top>
                </div>
              </el-tab-pane>
              <el-tab-pane label="IP地址范围" name="tabname_ip" v-if="loginuser_utype == 'G'">
                <div class="middle-tab-bottom">
                  <vxe-table show-overflow ref="ipTable" :data.sync="useripList" height="auto"
                    :sort-config="{ trigger: 'cell' }" :keyboard-local-config="keyLocalConfig" border size="mini"
                    show-header-overflow highlight-current-row resizable stripe header-align="center"
                    :edit-config="{ trigger: 'click', mode: 'row', showStatus: true, showIcon: false }">

                    <vxe-table-column field="userno" title="用户代号" width="120"></vxe-table-column>
                    <vxe-table-column field="iplist1" title="ip地址开始" width="120"
                      :edit-render="{ name: 'input', events: { change: HasChange }, }"></vxe-table-column>
                    <vxe-table-column field="iplist2" title="ip地址结束" width="120"
                      :edit-render="{ name: 'input', events: { change: HasChange }, }"></vxe-table-column>
                  </vxe-table>
                 
                </div>
                <div class="addBtn" style="font-size:17px;padding:3px;background-color:#fff;text-align:center;font-weight:bold;">
                        <el-button @click="btnDetailAdd" class="el-button--310">新增明细</el-button>
                        <el-button @click="btnDetailDel" class="el-button--310">删除明细</el-button>
                        <div style="color:red;font-size:12px;float:right;line-height:25px">ip地址开始和结束前三位要保持一致，否则将无法登陆成功。
                        </div>
                      </div>
              </el-tab-pane>
            </el-tabs>
          </div>
        </template>
        <div style="height:100%;width:100%;">
          <vxe-table :data.sync="MainTableData" :loading="MainLoading" :select-config="{ reserve: true }"
            :sort-config="{ trigger: 'cell' }" border height="auto" highlight-current-row highlight-hover-column
            highlight-hover-row how-header-overflow ref="Main_Table" resizable show-overflow size="mini" stripe
            @current-change="MainTableChange_Event" :row-class-name="RowClassName" show-header-overflow
            :optimization="{ animat: false }" header-align="center">
            <vxe-table-column field="userkind" sortable title="大类" width="60" show-overflow
              :formatter="['formatSelect', UserKindOption]"></vxe-table-column>
            <vxe-table-column field="userno" sortable title="代号" width="50" show-overflow></vxe-table-column>
            <vxe-table-column field="username" sortable title="名称" width="50" show-overflow></vxe-table-column>
            <vxe-table-column field="usernameen" sortable title="英文姓名" width="80" show-overflow></vxe-table-column>
            <vxe-table-column field="utype" sortable title="类型" width="70" show-overflow
              :formatter="['formatSelect', utypeOption]"></vxe-table-column>
            <vxe-table-column field="enabled" sortable title="可用" width="40" show-overflow align="center">
              <template v-slot="{ row }">
                <el-checkbox disabled true-label="1" false-label="0" v-model="row.enabled"></el-checkbox>
              </template>
            </vxe-table-column>
            <vxe-table-column field="defaultprg" sortable title="默认程序" width="70"></vxe-table-column>
            <!-- <vxe-table-column field="hospcode" sortable title="所属医院代码" width="100"></vxe-table-column> -->
            <vxe-table-column field="hospitalname" sortable title="所属医院名称" width="150"></vxe-table-column>
            <vxe-table-column field="hiscode1" sortable title="HIS系统对照1" width="90"></vxe-table-column>
            <vxe-table-column field="hiscode2" sortable title="平台认证码" width="90"></vxe-table-column>
            <vxe-table-column field="bk1" sortable title="备用1" width="70"></vxe-table-column>
            <vxe-table-column field="bk2" sortable title="备用2" width="70"></vxe-table-column>
            <vxe-table-column field="bk3" sortable title="备用3" width="70"></vxe-table-column>
            <vxe-table-column field="inputcode" sortable title="助记符" width="70"></vxe-table-column>
            <vxe-table-column field="doctorkind" sortable title="医生分级" width="100"
              :formatter="['formatSelect', $opt.doctorkindOption]"></vxe-table-column>
            <vxe-table-column field="doctormaster" sortable title="主任标志" width="90"
              :formatter="['formatSelect', doctormasterOption]"></vxe-table-column>
            <vxe-table-column field="deptno" sortable title="科室代码" width="120"></vxe-table-column>
            <vxe-table-column field="pass_dt" sortable title="密码更新时间" width="130"></vxe-table-column>
            <vxe-table-column field="idcardno" sortable title="身份证号" width="135"></vxe-table-column>
            <vxe-table-column field="wardno" sortable title="病区代码" width="90"></vxe-table-column>
            <vxe-table-column field="castartdt" sortable title="CA启用时间" width="130"></vxe-table-column>
          </vxe-table>
        </div>
      </rm-layout-right>

      <!-- <div class="middle-center" style="height: 100%">
          </div>
          <div class="middle-right">
          </div> -->
    </div>
    <!--设置初始密码--->
    <el-dialog title="提示" :visible.sync="dialogPrimaryPwd" width="500px" :close-on-click-modal="false">
      <div style="height:300px;margin:20px">
        <el-form ref="form" :model="PrimaryPwdObj" label-width="80px">
          <el-divider content-position="left">初始密码对象</el-divider>
          <el-form-item>
            <el-radio v-model="PrimaryPwdObj.setpwdobj" label="0">仅为空密码用户设置初始密码</el-radio>
          </el-form-item>
          <el-form-item>
            <el-radio v-model="PrimaryPwdObj.setpwdobj" label="1">为系统所有用户设置初始密码</el-radio>
          </el-form-item>
          <el-form-item>
            <el-radio v-model="PrimaryPwdObj.setpwdobj" label="2">为所选用户大类设置初始密码</el-radio>
            <el-select v-model="PrimaryPwdObj.sel_userkind" placeholder="请选择" style="width: 120px"
              :disabled="PrimaryPwdObj.setpwdobj != '2'" clearable>
              <el-option key="1" label="检验用户" value="1"></el-option>
              <el-option key="2" label="临床医生" value="2"></el-option>
              <el-option key="3" label="临床护士" value="3"></el-option>
              <el-option key="8" label="护工" value="8"></el-option>
              <el-option key="9" label="其它用户" value="9"></el-option>
            </el-select>
          </el-form-item>
          <el-divider content-position="left">设置初始密码</el-divider>
          <el-form-item>
            <el-radio v-model="PrimaryPwdObj.setpwdval" label="1" @change="setpwdvalChange">设置初始密码为系统用户工号</el-radio>
          </el-form-item>
          <el-form-item>
            <el-row>
              <el-col :span="8">
                <el-radio v-model="PrimaryPwdObj.setpwdval" label="0" @change="setpwdvalChange">初始密码自定义</el-radio>
              </el-col>
              <el-col :span="16">
                <el-input v-model="PrimaryPwdObj.myselfsetpwd" ref="refmyselfsetpwd" placeholder="输入初始密码"
                  :disabled="!PrimaryPwdObj.setpwddisabled" type="password" show-password></el-input>
              </el-col>
            </el-row>
          </el-form-item>
        </el-form>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="PrimaryPwdConfirm">确 定</el-button>
        <el-button @click="dialogPrimaryPwd = false">取 消</el-button>
      </span>
    </el-dialog>
    <el-dialog title="提示" v-el-drag-dialog :visible.sync="batchuoloaddialog" width="500px" :close-on-click-modal="false"
      v-if="batchuoloaddialog">
      <el-form :model="fileimportform">

        <div style="margin:20px">
          <p>此处可以批量上传用户签名</p>
          <p>批量选择一批文件，文件名必须是用户代号</p>
          <el-upload ref="uploadDat" action="" :limit=limitNum :auto-upload="false" drag accept=".jpg,.jpeg,.png"
            :multiple="true" :before-remove="handleFileRemove" :on-change="fileChange" :on-exceed="exceedFile"
            :file-list="fileimportform.fileList" list-type="picture">
            <i class="el-icon-upload"></i>
            <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
            <div class="el-upload__tip" slot="tip">只能上传jpg/png文件，且不超过2M</div>
          </el-upload>
        </div>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button size="small" type="primary" @click="uploadFile()">立即上传</el-button>
        <el-button @click="batchuoloaddialog = false">取 消</el-button>
      </span>
    </el-dialog>
    <!--hiscode1增加弹窗对医生字典选择功能--->
    <el-dialog v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" title="请选择医生"
      :visible.sync="hiscode1Dialog">
      <rm-pop-common @change="SelectDoctor" @cancel="hiscode1Dialog = false;" datatype="doctor"
        :key="hiscode1Dialogkey"></rm-pop-common>
    </el-dialog>
    <!--增加密码修改功能--->
    <el-dialog v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" title="修改密码"
      :visible.sync="pswObj.pswdialog" width="400px">
      <div style="padding:25px 50px 10px 50px">
        <el-form label-position="right" label-width="80px" :model="pswObj">
          <el-form-item label="用户代码">
            <el-input v-model="pswObj.userno" disabled></el-input>
          </el-form-item>
          <el-form-item label="用户名称">
            <el-input v-model="pswObj.username" disabled></el-input>
          </el-form-item>
          <el-form-item label="密码">
            <el-input v-model="pswObj.pwsfirst" placeholder="请输入密码" show-password></el-input>
          </el-form-item>
          <el-form-item label="确认密码">
            <el-input v-model="pswObj.pwssecond" placeholder="请输入密码" show-password></el-input>
          </el-form-item>
        </el-form>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="pswObjSave" icon="el-icon-document">确 定</el-button>
        <el-button @click="pswObj.pswdialog = false" icon="el-icon-close">取 消</el-button>
      </span>
    </el-dialog>
  </div>
</template>


<script>
import { Promise } from "q";
import md5 from "js-md5";
import { invalid } from "moment";
import XEUtils from "xe-utils";
import axios from "axios";
XEUtils.mixin({
  // 自定义全局的格式化处理函数
  formatSelect(cellValue, list) {
    let item = list.find((item) => item.value == cellValue);
    return item ? item.label : "";
  },
});
export default {
  name: "MNG110",
  data() {
    return {
      transfer_name: ["可选角色", "已有角色"],
      ifCanEditFlag: false,
      sel_strinput: "",
      sel_userkind: "",
      sel_doctorkind: "",
      sel_doctormaster: "",
      userno_disabled: false,
      changeflag: false,
      isRegLis: false,
      buttonwidth: "",
      MainTableData: [],
      hospOption: [],
      MainLoading: false,
      usersync: true,
      Tab_jbxx_Data: {
        userno: "",
        enabled: "0",
        username: "",
        usernameen: "",
        userkind: "1",
        utype: "U",
        doctorkind: "10",
        pwd: "",
        doctormaster: "0",
        defaultprg: "",
        hospcode: "All",
        hiscode1: "",
        hiscode2: "",
        bk1: "",
        bk2: "",
        bk3: "",
        inputcode: "",
        signnameimage: "",
        photoimage: "",
        caparm1: "",
        caparm2: "",
        caparm3: "",
        signnamefiletype: "",
        photofiletype: "",
        deptno: "",
        pass_dt: "",
        idcardno: "",
        wardno: "",
        castartdt: "",
        hospitalname: "",
      },
      TempTab_jbxx_Data: {
        userno: "",
        enabled: "0",
        username: "",
        usernameen: "",
        userkind: "1",
        utype: "U",
        doctorkind: "10",
        pwd: "",
        doctormaster: "0",
        defaultprg: "",
        hospcode: "All",
        hiscode1: "",
        hiscode2: "",
        bk1: "",
        bk2: "",
        bk3: "",
        inputcode: "",
        signnameimage: "",
        photoimage: "",
        caparm1: "",
        caparm2: "",
        caparm3: "",
        signnamefiletype: "",
        photofiletype: "",
        deptno: "",
        pass_dt: "",
        idcardno: "",
        wardno: "",
        castartdt: "",
        hospitalname: "",
      },
      selrow: {
        userno: "",
        username: "",
        usernameen: "",
        hospcode: "",
        hospitalname: "",
        utype: "",
        userkind: "",
        enabled: "",
        defaultprg: "",
        hiscode1: "",
        hiscode2: "",
        bk1: "",
        bk2: "",
        bk3: "",
        inputcode: "",
        doctorkind: "",
        doctormaster: "",
        deptno: "",
        pass_dt: "",
        idcardno: "",
        wardno: "",
        castartdt: "",
      },
      TempPhotoImageUrl: "",
      TempSignImageUrl: "",
      // temppwd1: "",
      // temppwd2: "",
      // temppwd3: "",
      repeat_pwd: "",
      tab_showflag: "tabname_jbxx",
      PhotoImageUrl: "",
      SignImageUrl: "",
      tab_dyjs_nohavenuser_data: [],
      tab_dyjs_havenuser_data: [],
      tab_dyyq_nohavenhosp_data: [],
      tab_dyyq_havenhosp_data: [],
      tab_dyyq_havenreg_data: [], //对应区域          
      tab_dyyq_nohavenreg_data: [],
      loginuser_utype: "",
      loginuser_hosp: "",
      tempindex: 0,
      actionindex: "M",
      hospitalval: "",
      okFirstLoading: false,
      userno: "",
      utypeOption: [
        { label: "", value: "" },
        { label: "普通用户", value: "U" },
        { label: "管理员", value: "G" },
        { label: "账户管理员", value: "C" },
        { label: "区域管理员", value: "R" },
        { label: "开发", value: "D" },
      ],
      UserKindOption: [
        { label: "", value: "" },
        { label: "检验用户", value: "1" },
        { label: "临床医生", value: "2" },
        { label: "临床护士", value: "3" },
        { label: "护工", value: "8" },
        { label: "其它用户", value: "9" },
      ],
      //主任标志
      doctormasterOption: [
        { label: "非主任", value: "0" },
        { label: "科副主任", value: "1" },
        { label: "科主任", value: "2" },
      ],
      AddData: [],
      ModData: [],
      exeflag: "1",
      pageinitloading: false,
      searchobj: { querylefthosp: "", queryleftregion: "", queryleftrole: "", queryleftreg: "" },
      deptno: "",
      IsAreaMode: false,
      dialogPrimaryPwd: false,
      hiscode1Dialog: false,
      hiscode1Dialogkey: 0,
      PrimaryPwdObj: { setpwdobj: "0", setpwdval: "1", myselfsetpwd: "", sel_userkind: "", setpwddisabled: false },
      batchuoloaddialog: false,
      fileList: [],
      fileimportform: { fileList: [] },
      limitNum: 99,
      successcount: 0,
      failcount: 0,
      finishcount: 0,
      totalcount: 0,
      importfileindex: 0,
      failname: "",
      useripList: [],
      keyLocalConfig: {
        isArrow: true,
      },
      pswObj: {
        userno: "",
        username: "",
        pwsfirst: "", //密码
        pwssecond: "", //确认密码
        pswdialog: false,
      },
      unlogindays: '0',
    };
  },
  created() {
    this.init_login();
    this.MainTable_Rfresh();
    this.$ddldata.IsAreaModeFun().then((r) => {
      this.isRegLis = r;
    }); //防止刷新页面导致IsAreaMode被清掉
  },
  computed: {
    userofreglist() {
      let filterName = this.searchobj.queryleftreg;
      if (filterName) {
        let rest = this.tab_dyyq_nohavenreg_data.filter((item) => {
          return (!!item.regionname ? item.regionname.toUpperCase().indexOf(filterName.toUpperCase()) > -1 : false) || (item.regioncode ? item.regioncode.toUpperCase().indexOf(filterName.toUpperCase()) > -1 : false);
        });
        return rest;
      } else {
        return this.tab_dyyq_nohavenreg_data;
      }
    },
    userofhosplist() {
      let filterName = this.searchobj.querylefthosp.trim();
      let filtetName_reg = this.searchobj.queryleftregion.trim();
      let data = this.tab_dyyq_nohavenhosp_data;
      // if (filterName) {
      //     let rest = this.tab_dyyq_nohavenhosp_data.filter((item) => {
      //         return (!!item.hospitalname ? item.hospitalname.toUpperCase().indexOf(filterName.toUpperCase()) > -1 : false) || (item.hospcode ? item.hospcode.toUpperCase().indexOf(filterName.toUpperCase()) > -1 : false);
      //     });
      //     return rest;
      // } else {
      //     return this.tab_dyyq_nohavenhosp_data;
      // }
      if (filterName || filtetName_reg) {
        if (filterName) {
          data = data.filter((item) => {
            return (!!item.hospitalname ? item.hospitalname.toUpperCase().indexOf(filterName.toUpperCase()) > -1 : false) || (item.hospcode ? item.hospcode.toUpperCase().indexOf(filterName.toUpperCase()) > -1 : false);
          });
        }
        if (filtetName_reg) {
          data = data.filter((item) => {
            return (!!item.regionname ? item.regionname.toUpperCase().indexOf(filtetName_reg.toUpperCase()) > -1 : false) || (item.regionid ? item.regionid.toUpperCase().indexOf(filtetName_reg.toUpperCase()) > -1 : false);
          });
        }
        return data;
      } else {
        return this.tab_dyyq_nohavenhosp_data;
      }
    },
    userofrolelist() {
      let filterName = this.searchobj.queryleftrole.trim();
      if (filterName) {
        let rest = this.tab_dyjs_nohavenuser_data.filter((item) => {
          return (!!item.rolename ? item.rolename.toUpperCase().indexOf(filterName.toUpperCase()) > -1 : false) || (item.roleno ? item.roleno.toUpperCase().indexOf(filterName.toUpperCase()) > -1 : false);
        });
        return rest;
      } else {
        return this.tab_dyjs_nohavenuser_data;
      }
    },
  },
  mounted() { },
  watch: {},
  updated() { },
  methods: {
    setPrimaryPwd() {
      this.PrimaryPwdObj.setpwdobj = "0";
      this.PrimaryPwdObj.setpwdval = "1";
      this.PrimaryPwdObj.myselfsetpwd = "";
      this.PrimaryPwdObj.sel_userkind = "";
      this.PrimaryPwdObj.setpwddisabled = false;
      this.dialogPrimaryPwd = true;
    },
    setpwdvalChange() {
      if (this.PrimaryPwdObj.setpwdval == "1") {
        this.PrimaryPwdObj.setpwddisabled = false;
      } else {
        this.PrimaryPwdObj.myselfsetpwd = "";
        this.$refs.refmyselfsetpwd.focus();
        this.PrimaryPwdObj.setpwddisabled = true;
      }
    },
    PrimaryPwdConfirm() {
      this.$confirm("你确定要为所选用户对象设置初始密码吗？", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          const rload = this.$loading({
            // 声明一个loading对象
            lock: true, // 是否锁屏
            text: "正在设置初始密码，请稍候……", // 加载动画的文字
            spinner: "el-icon-loading", // 引入的loading图标
            background: "rgba(0, 0, 0, 0.3)", // 背景颜色
            target: ".sub-main", // 需要遮罩的区域
            body: true,
            customClass: "mask", // 遮罩层新增类名
          });
          if (this.PrimaryPwdObj.setpwdval == "0") {
            //自定义初始密码
            this.PrimaryPwdObj.myselfsetpwd = md5("rms-" + this.PrimaryPwdObj.myselfsetpwd + "-rme");
          }
          this.$tool
            .request({
              url: "MNG/MNG1/MNG110",
              method: "post",
              timeout: 6000000,
              data: {
                action: "PrimaryPwdConfirm",
                ...this.PrimaryPwdObj,
              },
            })
            .then((res) => {
              rload.close();
              if (res.errcode == "1") {
                this.dialogPrimaryPwd = false;
                this.$alert("已为成功所选用户对象设置初始密码！", "提示");
              } else {
                this.$alert(res.errmsg, "提示");
              }
            })
            .catch((e) => {
              rload.close();
              this.$alert(e, "提示");
            });
        })
        .catch(() => { });
    },
    //初始化登陆者权限身份
    init_login() {
      this.$tool
        .request({
          url: "MNG/MNG1/MNG110",
          method: "post",
          data: {
            action: "get_loginuser",
          },
        })
        .then((res) => {
          this.loginuser_utype = res.utype;
          this.hospOption = res.hospoption;
          if (res.utype == "R" && res.IsAreaMode == true) {
            this.utypeOption = [
              { label: "", value: "" },
              { label: "普通用户", value: "U" },
              { label: "区域管理员", value: "R" },
            ];
          }
          this.unlogindays = res.unlogindays;
        })
        .catch((e) => {
          this.$message.error(e);
        });
      this.loginuser_hosp = this.$tool.getSession(this.$tool.selectedhis);
    },
    //主表查询
    async MainTable_Rfresh() {
      this.MainLoading = true;
      this.AddData = [];
      this.ModData = [];
      try {
        const res = await this.$tool.request({
          url: "MNG/MNG1/MNG110",
          method: "post",
          data: {
            action: "secsysuser_query",
            sel_strinput: this.sel_strinput,
            sel_userkind: this.sel_userkind,
            sel_doctorkind: this.sel_doctorkind,
            sel_doctormaster: this.sel_doctormaster,
            hospitalval: this.hospitalval,
            deptno: this.deptno,
          },
        });
        this.MainTableData = res.Data;
        this.okFirstLoading = true;
        if (res.Data.length > 0) {
          this.selrow = res.Data[0];
          this.userno = res.Data[0].userno;
          this.$refs.Main_Table.setCurrentRow(this.selrow);
          await this.getUserData();
        } else {
          this.userno = "";
          this.selrow = null;
          this.$refs.Main_Table.setCurrentRow(null);

          this.Tab_jbxx_Data = {
            userno: "",
            enabled: "0",
            username: "",
            usernameen: "",
            userkind: "1",
            utype: "U",
            doctorkind: "10",
            pwd: "",
            doctormaster: "0",
            defaultprg: "",
            hospcode: "All",
            hiscode1: "",
            hiscode2: "",
            bk1: "",
            bk2: "",
            bk3: "",
            inputcode: "",
            signnameimage: "",
            photoimage: "",
            caparm1: "",
            caparm2: "",
            caparm3: "",
            signnamefiletype: "",
            photofiletype: "",
            deptno: "",
            pass_dt: "",
            idcardno: "",
            wardno: "",
            castartdt: "",
            hospitalname: "",
          };
          this.PhotoImageUrl = "";
          this.SignImageUrl = "";
          //换行保存储备数据
          this.TempTab_jbxx_Data = XEUtils.clone(this.Tab_jbxx_Data, true);
          this.TempPhotoImageUrl = "";
          this.TempSignImageUrl = "";
          this.ifCanEditFlag = true;
        }

        if (this.tablabel == "对应角色") {
          await this.getRoleInfo();
        }
        if (this.tablabel == "对应院区") {
          await this.getHospInfo();
        }
        if (this.tablabel == "对应区域") {
          await this.getRegInfo();
        }
        if (this.tablabel == "IP地址范围") {
          await this.getIpList();
        }
        this.MainLoading = false;
      } catch (e) {
        this.$message.error(e);
      }
    },
    //获取行数据
    MainTableChange_Event({ row, rowIndex }, event) {
      try {
        //行改变修改
        if (row.syncflag == "0") {
          //非同步数据
          if (this.exeflag == "1" && !this.pageinitloading) {
            this.$nextTick(async () => {
              await this.MainTableChange_EventFun(row, rowIndex);
            });
          } else {
            this.$refs.Main_Table.setCurrentRow(this.selrow);
            return;
          }
        } else {
          //是同步数据
          if (this.pageinitloading == false) {
            this.$nextTick(async () => {
              await this.setvalueToForm(row);
            });
          } else {
            this.$refs.Main_Table.setCurrentRow(this.selrow);
            return;
          }
        }
      } catch (e) {
        this.$alert(e, "提示", {
          confirmButtonText: "确定",
        });
      }
    }, //行选中
    async MainTableChange_EventFun(row, rowIndex) {
      //    this.tempindex = rowIndex;
      this.userno = row.userno;
      if (this.tab_showflag == "tabname_jbxx" || this.tab_showflag == "tabname_ip") {
        //查用户基本信息
        this.exeflag == "0";
        this.save()
          .then(() => {
            this.selrow = row;
            this.userno = row.userno;
            this.$refs.Main_Table.setCurrentRow(row);
            this.$nextTick(async () => {
              await this.getUserData();
              await this.getIpList();
              this.exeflag = "1";
            });
          })
          .catch((ex) => {
            this.$refs.Main_Table.setCurrentRow(this.selrow);
            this.exeflag = "1";
          });
      } else if (this.tab_showflag == "tabname_dyjs") {
        //查对应角色
        await this.getRoleInfo();
      } else if (this.tab_showflag == "tabname_dyyq") {
        //查对应院区
        await this.getHospInfo();
      } else if (this.tab_showflag == "tabname_dyqy") {
        //查对应区域
        await this.getRegInfo();
      }
    }, //行切换保存
    save() {
      return new Promise((s, f) => {
        let haschange = false;
        let saveinfo = XEUtils.clone(this.Tab_jbxx_Data, true);
        if (this.actionindex == "M") {
          //如果是修改
          if (!XEUtils.isEqualWith(this.TempTab_jbxx_Data, saveinfo)) {
            //表单被更改
            haschange = true;
          }
          if (!XEUtils.isEqualWith(this.TempPhotoImageUrl, this.PhotoImageUrl)) {
            //用户照片被更改
            haschange = true;
          }
          if (!XEUtils.isEqualWith(this.TempSignImageUrl, this.SignImageUrl)) {
            //电子签名被更改
            haschange = true;
          }
        } else if (this.actionindex == "A") {
          //如果是新增
          haschange = true;
        }

        if (saveinfo.userno == "") {
          this.$alert("用户代号不可为空！", "提示", {
            confirmButtonText: "确定",
          });
          this.$refs.txtusernoid.focus();
          f();
          return;
        }
        if (saveinfo.username == "") {
          this.$alert("用户名称不可为空！", "提示", {
            confirmButtonText: "确定",
          });
          this.$refs.txtusernameid.focus();
          f();
          return;
        }
        if (saveinfo.hospcode.trim() == "") {
          this.$alert("医院代码不可为空！", "提示", {
            confirmButtonText: "确定",
          });
          f();
          return;
        }
        if (saveinfo.utype == "") {
          this.$alert("用户类型不可为空！", "提示", {
            confirmButtonText: "确定",
          });
          f();
          return;
        }
        if (saveinfo.hospcode.trim() == "") {
          this.$alert("所属医院不可为空！", "提示", {
            confirmButtonText: "确定",
          });
          f();
          return;
        }
        if (saveinfo.enabled == "") {
          this.$alert("是否可用不可为空！", "提示", {
            confirmButtonText: "确定",
          });
          f();
          return;
        }
        // let reallyPwd = "";
        // if (this.temppwd2 != this.temppwd3) {
        //     //temppwd1为原始密码，2为修改密码，3为确认密码
        //     this.$alert("两次密码必须一致！", "提示", {
        //         confirmButtonText: "确定",
        //     });
        //     f();
        //     return;
        // } else {
        //     if (saveinfo.pwd == "**************") {
        //         //表示空密码
        //         if (this.temppwd2 == "") {
        //             //没有改变过
        //             reallyPwd = this.temppwd1;
        //         } else {
        //             //密码已经改变
        //             reallyPwd = this.temppwd2;
        //         }
        //         saveinfo.pwd = "";
        //     } else if (saveinfo.pwd == "****************") {
        //         //表示密码不为空被转义但没有改变过,赋值为原来的值
        //         if (this.temppwd2 == "") {
        //             //没有改变过
        //             reallyPwd = this.temppwd1;
        //         } else {
        //             //已经改变过
        //             reallyPwd = this.temppwd2;
        //         }
        //     } else {
        //         reallyPwd = this.temppwd2;
        //         //表示密码被改变过
        //     }
        //     saveinfo.pwd = md5("rms-" + reallyPwd + "-rme");
        // }
        if (this.$refs.ipTable && this.$refs.ipTable.tableData.length > 0) {
          var datatable = this.$refs.ipTable.tableData;
          var hasnul = false;
          datatable.forEach((element) => {
            if (!hasnul) {
              if (!element.userno || !element.iplist1 || !element.iplist2) {
                hasnul = true;
              }
            }
          });
          if (hasnul) {
            this.$alert("IP地址范围开始和结束地址不允许为空！", "提示", {
              confirmButtonText: "确定",
            });
            f();
            return;
          }
        }
        let ipsaveinfo = "";
        if (this.$refs.ipTable) {
          ipsaveinfo = this.$refs.ipTable.getRecordset();
        }
        delete eval(saveinfo).hospitalname;
        if (haschange) {
          this.isDelOldHosp().then((resp) => {
            this.$nextTick(async () => {
              const res = await this.$tool.request({
                url: "MNG/MNG1/MNG110",
                method: "post",
                data: {
                  action: "secsysuser_addedit",
                  data: saveinfo,
                  delhospcodeflag: resp,
                  ipsaveinfo: ipsaveinfo,
                },
              });
              if (res.errcode == "1") {
                this.$pub.message(this, "保存成功！", "success");
                this.changeflag = false;
                this.userno = res.userno;
                //不是删除操作
                if (this.actionindex == "A") {
                  //新增数据成功后医院名称赋值
                  let hospname = this.hospOption.find((m) => m.value == saveinfo.hospcode);
                  if (hospname != undefined) {
                    saveinfo.hospitalname = hospname.label;
                  }
                  //新增数据成功后的不刷新操作
                  this.$refs.Main_Table.insertAt(saveinfo, -1).then(({ row }) => {
                    this.$refs.Main_Table.setCurrentRow(row);
                    this.selrow = row;
                  });
                  if (this.AddData.indexOf(this.userno) < 0) {
                    this.AddData.push(this.userno);
                  }
                  // this.tempindex = this.$refs.Main_Table.tableData.length - 1;
                } else if (this.actionindex == "M") {
                  let hospname = this.hospOption.find((m) => m.value == saveinfo.hospcode);
                  if (hospname != undefined) {
                    saveinfo.hospitalname = hospname.label;
                  }
                  this.setvalueToTable(saveinfo);
                  if (this.ModData.indexOf(this.userno) < 0) {
                    this.ModData.push(this.userno);
                  }
                }
                //不刷后台，照片改变后不能获得最新的改变的图片
                this.actionindex = "M";
                s();
              } else {
                this.$message.error("保存失败！" + res.errmsg);
                f();
              }
            });
          });
        } else {
          this.changeflag = false;
          s();
        }
      });
    }, //是否剔除原来的医院
    isDelOldHosp() {
      let delhospcodeflag = "0";
      let aPromise = new Promise((resolve) => {
        if (this.actionindex == "M") {
          //如果是修改
          if (this.TempTab_jbxx_Data.hospcode != this.Tab_jbxx_Data.hospcode) {
            this.$confirm("是否剔除原来的医院?", "提示", {
              confirmButtonText: "是",
              cancelButtonText: "否",
              focusCancelButton: true,
              type: "warning",
              showClose: false,
            })
              .then(() => {
                delhospcodeflag = "1";
                resolve(delhospcodeflag);
              })
              .catch(() => {
                delhospcodeflag = "0";
                resolve(delhospcodeflag);
              });
          } else {
            delhospcodeflag = "0";
            resolve(delhospcodeflag);
          }
        } else {
          delhospcodeflag = "0";
          resolve(delhospcodeflag);
        }
      });
      return aPromise;
    }, //同步数据时赋值给表单
    async setvalueToForm(obj) {
      this.pageinitloading = true;
      this.Tab_jbxx_Data.userno = obj.userno;
      this.Tab_jbxx_Data.username = obj.username;
      this.Tab_jbxx_Data.usernameen = obj.usernameen;
      this.Tab_jbxx_Data.hospcode = obj.hospcode;
      this.Tab_jbxx_Data.utype = obj.utype;
      this.Tab_jbxx_Data.userkind = obj.userkind;
      this.Tab_jbxx_Data.enabled = obj.enabled;
      this.Tab_jbxx_Data.defaultprg = obj.defaultprg;
      this.Tab_jbxx_Data.hiscode1 = obj.hiscode1;
      this.Tab_jbxx_Data.hiscode2 = obj.hiscode2;
      this.Tab_jbxx_Data.bk1 = obj.bk1;
      this.Tab_jbxx_Data.bk2 = obj.bk2;
      this.Tab_jbxx_Data.bk3 = obj.bk3;
      this.Tab_jbxx_Data.inputcode = obj.inputcode;
      this.Tab_jbxx_Data.doctorkind = obj.doctorkind;
      this.Tab_jbxx_Data.doctormaster = obj.doctormaster;
      this.Tab_jbxx_Data.deptno = obj.deptno;
      this.Tab_jbxx_Data.pass_dt = obj.pass_dt;
      this.Tab_jbxx_Data.idcardno = obj.idcardno;
      this.Tab_jbxx_Data.wardno = obj.wardno;
      this.Tab_jbxx_Data.castartdt = obj.castartdt; // XEUtils.toDateString(obj.castartdt, "yyyy-MM-dd HH:mm:ss");
      this.PhotoImageUrl = "";
      this.SignImageUrl = "";

      //换行保存储备数据
      this.TempTab_jbxx_Data = XEUtils.clone(this.Tab_jbxx_Data, true);
      this.TempPhotoImageUrl = "";
      this.TempSignImageUrl = "";
      this.pageinitloading = false;
    }, //表单修改时赋值给行
    async setvalueToTable(obj) {
      this.$nextTick(() => {
        try {
          let value = obj.hospcode;
          let item = this.hospOption.find((item) => item.value == value);
          obj.hospitalname = item.label;
        } catch (e) {
          obj.hospitalname = obj.hospcode;
        }
        this.selrow.userno = obj.userno;
        this.selrow.username = obj.username;
        this.selrow.usernameen = obj.usernameen;
        this.selrow.hospcode = obj.hospcode;
        this.selrow.hospitalname = obj.hospitalname;
        this.selrow.utype = obj.utype;
        this.selrow.userkind = obj.userkind;
        this.selrow.enabled = obj.enabled;
        this.selrow.defaultprg = obj.defaultprg;
        this.selrow.hiscode1 = obj.hiscode1;
        this.selrow.hiscode2 = obj.hiscode2;
        this.selrow.bk1 = obj.bk1;
        this.selrow.bk2 = obj.bk2;
        this.selrow.bk3 = obj.bk3;
        this.selrow.inputcode = obj.inputcode;
        this.selrow.doctorkind = obj.doctorkind;
        this.selrow.doctormaster = obj.doctormaster;
        this.selrow.deptno = obj.deptno;
        this.selrow.pass_dt = obj.pass_dt;
        this.selrow.idcardno = obj.idcardno;
        this.selrow.wardno = obj.wardno;
        this.selrow.castartdt = XEUtils.toDateString(obj.castartdt, "yyyy-MM-dd HH:mm:ss");
      });
    },
    //tab切换
    async tab_getdata(tab, event) {
      this.tablabel = tab.label;
      if (tab.label == "详细信息") {
        await this.getUserData();
      } else if (tab.label == "对应角色") {
        setTimeout(() => {
          if (this.$refs.refqueryleftrole) this.$refs.refqueryleftrole.focus();
        }, 10);
        await this.getRoleInfo();
      } else if (tab.label == "对应院区") {
        setTimeout(() => {
          if (this.$refs.refquerylefthosp) this.$refs.refquerylefthosp.focus();
        }, 10);
        await this.getHospInfo();
      } else if (tab.label == "对应区域") {
        setTimeout(() => {
          if (this.$refs.refqueryleftreg) this.$refs.refqueryleftreg.focus();
        }, 10);
        await this.getRegInfo();
      } else if (tab.label == "IP地址范围") {
        await this.getIpList();
      }
      this.searchobj = { querylefthosp: "", queryleftregion: "", queryleftrole: "", queryleftreg: "" };
    },
    //获取对应角色
    async getUserData() {
      try {
        this.userno_disabled = true; //用户代码不允许修改
        this.pageinitloading = true;
        const res = await this.$tool.request({
          url: "MNG/MNG1/MNG110",
          method: "post",
          data: {
            action: "getuser_byuserno",
            userno: this.userno,
          },
        });

        if (res.data.length > 0) {
          //密码以*显示
          // this.temppwd1 = XEUtils.clone(res.data[0].pwd, true); //记录原密码
          // res.data[0].pwd = res.data[0].pwd == null || res.data[0].pwd == "" ? "**************" : "****************";
          // this.repeat_pwd = XEUtils.clone(res.data[0].pwd, true);

          //表单赋值
          //这里因为密码问题导致不能实体赋值，不然因为change事件pwd: "d6c9e668a0ebf4c87804f332d207c4a1"||pwd: "****************"导致进入保存
          this.Tab_jbxx_Data = res.data[0];
          this.PhotoImageUrl = res.photoPic;
          this.SignImageUrl = res.signPic;
          //换行保存储备数据
          this.TempTab_jbxx_Data = XEUtils.clone(this.Tab_jbxx_Data, true);
          this.TempPhotoImageUrl = XEUtils.clone(res.photoPic, true);
          this.TempSignImageUrl = XEUtils.clone(res.signPic, true);
          this.ifCanEditFlag = false;
        } else {
          this.tab_jbxx_addEvent(2);
          this.ifCanEditFlag = true;
        }
        this.pageinitloading = false;
      } catch (e) {
        this.$alert(e, "提示", {
          confirmButtonText: "确定",
        });
        this.pageinitloading = false;
      }
    },
    //密码修改
    // inputChange(e) {
    //     var re = "";
    //     var val = "";
    //     for (var i = 0; i < e.length; i++) {
    //         re += "*";
    //     }
    //     this.Tab_jbxx_Data.pwd = re;
    //     this.temppwd2 = e;
    // }, //确认密码修改
    // inputChange_confirm(e) {
    //     var re = "";
    //     for (var i = 0; i < e.length; i++) {
    //         re += "*";
    //     }
    //     this.repeat_pwd = re;
    //     this.temppwd3 = e;
    //     if (this.temppwd3 != "" && this.temppwd2 != "") {
    //         if (this.temppwd2 != this.temppwd3) {
    //             this.$message.error("两次密码必须一致！");
    //         }
    //     }
    // }, //密码清除
    // pwdClear(type) {
    //     if (type == "1") {
    //         //密码清除
    //         this.temppwd2 = "";
    //         setTimeout(() => {
    //             if (this.$refs.RefPwd1) this.$refs.RefPwd1.focus();
    //         }, 10);
    //     } else {
    //         //确认密码清除
    //         this.temppwd3 = "";
    //         setTimeout(() => {
    //             if (this.$refs.RefPwd2) this.$refs.RefPwd2.focus();
    //         }, 10);
    //     }
    // },
    //获取对应角色
    async getRoleInfo() {
      try {
        if (!this.userno) {
          this.tab_dyjs_nohavenuser_data = [];
          this.tab_dyjs_havenuser_data = [];
        } else {
          const res = await this.$tool.request({
            url: "MNG/MNG1/MNG110",
            method: "post",
            data: {
              action: "secsysrole_get",
              userno: this.userno,
            },
          });
          this.tab_dyjs_nohavenuser_data = res[0];
          this.tab_dyjs_havenuser_data = res[1];
        }
      } catch (e) {
        this.$alert(e, "提示", {
          confirmButtonText: "确定",
        });
      }
    },
    //获取对应院区
    async getHospInfo() {
      try {
        if (!this.userno) {
          this.tab_dyyq_nohavenhosp_data = [];
          this.tab_dyyq_havenhosp_data = [];
        } else {
          const res = await this.$tool.request({
            url: "MNG/MNG1/MNG110",
            method: "post",
            data: {
              action: "secuserhosp_get",
              userno: this.userno,
            },
          });
          this.tab_dyyq_nohavenhosp_data = res[0];
          this.tab_dyyq_havenhosp_data = res[1];
        }
      } catch (e) {
        this.$alert(e, "提示", {
          confirmButtonText: "确定",
        });
      }
    },
    //获取对应区域
    async getRegInfo() {
      try {
        if (!this.userno) {
          this.tab_dyyq_nohavenreg_data = [];
          this.tab_dyyq_havenreg_data = [];
        } else {
          const res = await this.$tool.request({
            url: "MNG/MNG1/MNG110",
            method: "post",
            data: {
              action: "secuserreg_get",
              userno: this.userno,
            },
          });
          this.tab_dyyq_nohavenreg_data = res[0];
          this.tab_dyyq_havenreg_data = res[1];
        }
      } catch (e) {
        this.$alert(e, "提示", {
          confirmButtonText: "确定",
        });
      }
    }, //新增
    tab_jbxx_addEvent(flag) {
      try {
        this.actionindex = "A";
        this.ifCanEditFlag = false;
        if (flag == "1") this.changeflag = true;
        if (this.$refs.txtusernoid) this.$refs.txtusernoid.focus();
        this.Tab_jbxx_Data.userno = "";
        this.Tab_jbxx_Data.enabled = "1";
        this.Tab_jbxx_Data.username = "";
        this.Tab_jbxx_Data.usernameen = "";
        this.Tab_jbxx_Data.userkind = "1";
        this.Tab_jbxx_Data.utype = "U";
        this.Tab_jbxx_Data.doctorkind = "10";
        this.Tab_jbxx_Data.pwd = "";
        this.repeat_pwd = "";
        this.Tab_jbxx_Data.doctormaster = "0";
        this.Tab_jbxx_Data.defaultprg = "";
        this.Tab_jbxx_Data.hospcode = this.loginuser_hosp; //新增的医院只能是当前登录医院
        this.Tab_jbxx_Data.hiscode1 = "";
        this.Tab_jbxx_Data.hiscode2 = "";
        this.Tab_jbxx_Data.bk1 = "";
        this.Tab_jbxx_Data.bk2 = "";
        this.Tab_jbxx_Data.bk3 = "";
        this.Tab_jbxx_Data.inputcode = "";
        this.Tab_jbxx_Data.signnameimage = "";
        this.Tab_jbxx_Data.photoimage = "";
        this.Tab_jbxx_Data.caparm1 = "";
        this.Tab_jbxx_Data.caparm2 = "";
        this.Tab_jbxx_Data.caparm3 = "";
        this.Tab_jbxx_Data.signnamefiletype = "";
        this.Tab_jbxx_Data.photofiletype = "";
        this.Tab_jbxx_Data.deptno = "";
        this.Tab_jbxx_Data.pass_dt = this.$pub.InitDateTime(); //formatDate(new Date(), "yyyy-MM-dd HH:mm:ss");
        this.Tab_jbxx_Data.idcardno = "";
        this.Tab_jbxx_Data.wardno = "";
        this.Tab_jbxx_Data.syncflag = "0";
        this.Tab_jbxx_Data.castartdt = this.$pub.InitDateTime(); //.formatDate(new Date(), "yyyy-MM-dd HH:mm:ss");
        this.userno_disabled = false;
        this.ifCanEditFlag = false;
        this.PhotoImageUrl = "";
        this.SignImageUrl = "";

        if (flag == "2") {
          this.TempTab_jbxx_Data = XEUtils.clone(this.Tab_jbxx_Data, true);
          this.TempPhotoImageUrl = "";
          this.TempSignImageUrl = "";
        }
      } catch (e) {
        alert(e, "出错");
      }
    },
    //删除
    tab_jbxx_delete() {
      if (this.userno == "") {
        this.$message.error("请先选择数据！");
        return false;
      }
      if (this.userno.toUpperCase() == "ADMIN") {
        this.$message.error("系统管理员不可被删除！");
        return false;
      }
      this.$confirm("此操作将永久删除该人员, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.$tool
            .request({
              url: "MNG/MNG1/MNG110",
              method: "post",
              data: {
                action: "secsysuser_delete",
                userno: this.userno,
              },
            })
            .then((res) => {
              if (res.errcode == "1") {
                this.$message({
                  message: "删除成功！",
                  type: "success",
                });
                this.actionindex = "M";
                //是删除操作
                var delrow = this.$refs.Main_Table.getCurrentRow();
                if (delrow) {
                  var alld = this.$refs.Main_Table.getTableData().fullData;
                  var rowindex = alld.indexOf(delrow);
                  this.$refs.Main_Table.remove(delrow);
                  setTimeout(async () => {
                    let havedata = this.$refs.Main_Table.tableData;
                    if (havedata.length > 0) {
                      if (rowindex >= havedata.length) rowindex = havedata.length - 1;
                      let selectrow = havedata[rowindex];
                      this.$refs.Main_Table.setCurrentRow(selectrow);
                      this.userno = selectrow.userno;
                      await this.getUserData(); //this.MainTableChange_EventFun(selectrow, rowindex);
                      this.$refs.Main_Table.scrollToRow(selectrow);
                    } else {
                      this.MainTable_Rfresh();
                    }
                  }, 5);
                }
                this.ifCanEditFlag = false;
              } else {
                this.$message.error("删除失败！" + res.errmsg);
              }
            })
            .catch((e) => {
              this.$message.error(e);
            });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
    //取消
    async tab_jbxx_close() {
      this.changeflag = false;
      this.actionindex = "M";
      let row = this.$refs.Main_Table.getCurrentRow();
      if (!!row) {
        this.userno = row.userno;
        await this.getUserData();
        await this.getIpList();
      } else {
        this.userno = "";
        await this.getUserData();
        await this.getIpList();
      }
    },
    //保存
    tab_jbxx_save() {
      //转换checkbox
      var gData = XEUtils.clone(this.Tab_jbxx_Data, true);
      if (gData.userno == "") {
        this.$message.error("用户代号不可为空！");
        this.$refs.txtusernoid.focus();
        return false;
      }
      if (gData.username == "") {
        this.$alert("用户名称不可为空！", "提示", {
          confirmButtonText: "确定",
        });
        this.$refs.txtusernameid.focus();
        return false;
      }
      if (gData.hospcode == "") {
        this.$alert("医院代码不可为空！", "提示", {
          confirmButtonText: "确定",
        });
        return false;
      }
      if (gData.utype == "") {
        this.$alert("用户类型不可为空！", "提示", {
          confirmButtonText: "确定",
        });
        return false;
      }
      if (gData.enabled == "") {
        this.$alert("是否可用不可为空！", "提示", {
          confirmButtonText: "确定",
        });
        return false;
      }
      if (gData.hospcode == "") {
        this.$alert("所属医院不可为空！", "提示", {
          confirmButtonText: "确定",
        });
        return false;
      }
      // let reallyPwd = "";
      // if (this.temppwd2 != this.temppwd3) {
      //     //temppwd1为原始密码，2为修改密码，3为确认密码
      //     this.$message.error("两次密码必须一致！");
      //     return false;
      // } else {
      //     if (this.Tab_jbxx_Data.pwd == "**************") {
      //         //表示空密码
      //         if (this.temppwd2 == "") {
      //             //没有改变过
      //             reallyPwd = this.temppwd1;
      //         } else {
      //             //密码已经改变
      //             reallyPwd = this.temppwd2;
      //             gData.pwd = md5("rms-" + reallyPwd + "-rme");
      //         }
      //         this.Tab_jbxx_Data.pwd = "";
      //     } else if (this.Tab_jbxx_Data.pwd == "****************") {
      //         //表示密码不为空被转义但没有改变过,赋值为原来的值
      //         if (this.temppwd2 == "") {
      //             //没有改变过
      //             reallyPwd = this.temppwd1;
      //         } else {
      //             //已经改变过
      //             reallyPwd = this.temppwd2;
      //             gData.pwd = md5("rms-" + reallyPwd + "-rme");
      //         }
      //     } else {
      //         reallyPwd = this.temppwd2;
      //         //表示密码被改变过
      //         gData.pwd = md5("rms-" + reallyPwd + "-rme");
      //     }
      //     //gData.pwd = md5("rms-" + reallyPwd + "-rme");
      // }

      if (this.$refs.ipTable && this.$refs.ipTable.tableData.length > 0) {
        var datatable = this.$refs.ipTable.tableData;
        var hasnul = false;
        datatable.forEach((element) => {
          if (!hasnul) {
            if (!element.userno || !element.iplist1 || !element.iplist2) {
              hasnul = true;
            }
          }
        });
        if (hasnul) {
          this.$alert("IP地址范围开始和结束地址不允许为空！", "提示", {
            confirmButtonText: "确定",
          });
          return false;
        }
      }
      //此处
      let delhospcodeflag = "0";
      if (this.actionindex == "M") {
        //如果是修改
        if (this.TempTab_jbxx_Data.hospcode != this.Tab_jbxx_Data.hospcode) {
          this.$confirm("是否剔除原来的医院?", "提示", {
            confirmButtonText: "是",
            cancelButtonText: "否",
            focusCancelButton: true,
            type: "warning",
            showClose: false,
          })
            .then(() => {
              delhospcodeflag = "1";
              this.tab_jbxx_save_exe(gData, delhospcodeflag);
            })
            .catch(() => {
              delhospcodeflag = "0";
              this.tab_jbxx_save_exe(gData, delhospcodeflag);
            });
        } else {
          this.tab_jbxx_save_exe(gData, delhospcodeflag);
        }
      } else {
        this.tab_jbxx_save_exe(gData, delhospcodeflag);
      }
    },
    tab_jbxx_save_exe(gData, delhospcodeflag) {
      let ipsaveinfo = "";
      if (this.$refs.ipTable) {
        ipsaveinfo = this.$refs.ipTable.getRecordset();
      }
      delete eval(gData).hospitalname;
      this.$tool
        .request({
          url: "MNG/MNG1/MNG110",
          method: "post",
          data: {
            action: "secsysuser_addedit",
            data: gData,
            delhospcodeflag: delhospcodeflag,
            actionindex: this.actionindex,
            ipsaveinfo: ipsaveinfo,
          },
        })
        .then((res) => {
          if (res.errcode == "1") {
            this.$pub.message(this, "保存成功！", "success");
            this.userno = res.userno;
            this.changeflag = false;
            //不是删除操作
            if (this.actionindex == "A") {
              //新增数据成功后医院名称赋值
              let hospname = this.hospOption.find((m) => m.value == gData.hospcode);
              if (hospname != undefined) {
                gData.hospitalname = hospname.label;
              }
              //新增数据成功后的不刷新操作
              this.$refs.Main_Table.insertAt(gData, -1).then(({ row }) => {
                this.$refs.Main_Table.setCurrentRow(row);
                this.selrow = row;
              });
              if (this.AddData.indexOf(this.userno) < 0) {
                this.AddData.push(this.userno);
              }
              //   this.tempindex = this.$refs.Main_Table.tableData.length - 1;
            } else if (this.actionindex == "M") {
              let hospname = this.hospOption.find((m) => m.value == gData.hospcode);
              if (hospname != undefined) {
                gData.hospitalname = hospname.label;
              }
              this.setvalueToTable(gData);
              if (this.ModData.indexOf(this.userno) < 0) {
                this.ModData.push(this.userno);
              }
            }
            //不刷后台，照片改变后不能获得最新的改变的图片
            this.selrow = this.$refs.Main_Table.getCurrentRow();
            this.actionindex = "M";
            setTimeout(async () => {
              if (this.selrow) {
                await this.getUserData(); //查后台记录当前的值方便比较保存后值是否发生改变
                this.$refs.Main_Table.setCurrentRow(this.selrow);
                this.$refs.Main_Table.scrollToRow(this.selrow);
              }
            }, 5);
          } else {
            this.actionindex = this.actionindex;
            this.$message.error("保存失败！" + res.errmsg);
          }
        })
        .catch((e) => {
          this.$message.error(e);
        });
    }, //默认程序修改
    defaultprgChange(code, name) {
      if (this.TempTab_jbxx_Data.defaultprg != code) {
        this.Tab_jbxx_Data.defaultprg = code;
        this.changeflag = true;
      } else {
        this.changeflag = false;
      }
    }, //用户照片修改
    photoimagechange(file) {
      let _this = this;
      if (this.imagebefore(file)) {
        _this.changeflag = true;
        this.PhotoImageUrl = URL.createObjectURL(file.raw);
        var reader = new FileReader();
        reader.readAsDataURL(file.raw);
        reader.onload = function () {
          _this.Tab_jbxx_Data.photoimage = reader.result.toString();
          _this.Tab_jbxx_Data.photofiletype = file.name.split(".")[1].toString();
        };
        reader.onerror = function (error) {
          console.log("Error: ", error);
        };
      }
    }, //用户签名修改
    signimagechange(file) {
      let _this = this;
      if (this.imagebefore(file)) {
        _this.changeflag = true;
        this.SignImageUrl = URL.createObjectURL(file.raw);
        var reader = new FileReader();
        reader.readAsDataURL(file.raw);
        reader.onload = function () {
          _this.Tab_jbxx_Data.signnameimage = reader.result.toString();
          _this.Tab_jbxx_Data.signnamefiletype = file.name.split(".")[1].toString();
        };
        reader.onerror = function (error) {
          console.log("Error: ", error);
        };
      }
    },
    imagebefore(file) {
      const isLt2M = file.size / 1024 / 1024 < 2;
      const isJPG = file.raw.type == "image/png" || file.raw.type == "image/jpeg" || file.raw.type == "image/jpg";
      if (!isJPG) {
        this.$message.error("只能上传图片格式(png,jpeg,jpg)!");
      }
      if (!isLt2M) {
        this.$message.error("上传图片大小不能超过 2MB!");
      }
      return isJPG && isLt2M;
    },
    // formatDate(date, fmt) {
    //     alert(11);
    //     if (/(y+)/.test(fmt)) {
    //         fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
    //     }
    //     let o = {
    //         "M+": date.getMonth() + 1,
    //         "d+": date.getDate(),
    //         "H+": date.getHours(),
    //         "m+": date.getMinutes(),
    //         "s+": date.getSeconds(),
    //     };
    //     for (let k in o) {
    //         if (new RegExp(`(${k})`).test(fmt)) {
    //             let str = o[k] + "";
    //             fmt = fmt.replace(RegExp.$1, RegExp.$1.length === 1 ? str : this.padLeftZero(str));
    //         }
    //     }
    //     return fmt;
    // },
    // padLeftZero(str) {
    //     return ("00" + str).substr(str.length);
    // },
    //行颜色
    RowClassName({ row, rowIndex }) {
      if (!this.usersync) {
        let isDirty = this.$refs.Main_Table.hasRowChange(row);
        if (isDirty) {
          return "row-modify";
        }
        if (this.$refs.Main_Table.hasRowInsert(row)) return "row-new";
      } else {
        if (row.enabled != "1") {
          return "rm-disable"; //禁用
        }
        if (this.AddData.indexOf(row.userno) > -1) {
          return "row-new";
        }
        if (this.ModData.indexOf(row.userno) > -1) {
          return "row-modify";
        }
      }
    },
    //所属医院改变
    hospChange(code, name) {
      this.Tab_jbxx_Data.hospitalname = name;
      this.Tab_jbxx_Data.hospcode = code;
      this.changeflag = true;
    }, //同步
    syncData() {
      this.MainLoading = true;
      this.$tool
        .request({
          url: "MNG/MNG1/MNG110",
          method: "post",
          timeout: 600000,
          data: {
            action: "syncdata",
          },
        })
        .then((response) => {
          if (response.err == 0) {
            let msg = response.msg;
            if (!msg) msg = "同步数据获取失败！";
            this.MainLoading = false;
            this.$alert(msg, "信息");
            return;
          }
          let msg = response.msg;
          if (!msg) msg = "用户字典同步完成！";
          this.$alert(msg);
          this.MainTable_Rfresh();
        })
        .catch((e) => {
          console.log("error", e);
          this.MainLoading = false;
        });
    },
    // syncData() {
    //     this.MainLoading = true;
    //     this.$tool
    //         .request({
    //             url: "MNG/MNG1/MNG110",
    //             method: "post",
    //             data: {
    //                 action: "syncdata",
    //             },
    //         })
    //         .then((response) => {
    //             if (response == "-1") {
    //                 this.$message({
    //                     type: "warining",
    //                     message: "用户管理数据同步出错，最少应传递两列值！",
    //                 });
    //                 this.MainLoading = false;
    //                 return false;
    //             }
    //             if (response == "0") {
    //                 this.$message({
    //                     type: "warining",
    //                     message: "没有需要同步的用户管理数据！",
    //                 });
    //                 this.MainLoading = false;
    //                 return false;
    //             }
    //             let datatable = this.$refs.Main_Table.tableData;
    //             let _this = this;
    //             response.forEach((item) => {
    //                 let rest = datatable.filter((element) => element.userno == item.userno);
    //                 if (rest.length > 0) {
    //                     try {
    //                         rest.forEach((ele) => {
    //                             if (ele.userno == item.userno) {
    //                                 ele.syncflag = item.syncflag;
    //                                 ele.username = item.username == "" ? ele.username : item.username;
    //                                 let userkind = "";
    //                                 if (item.userkind == "" || item.userkind == null) {
    //                                     if (ele.userkind == "" || ele.userkind == null) {
    //                                         userkind = "";
    //                                     } else {
    //                                         userkind = ele.userkind;
    //                                     }
    //                                 } else {
    //                                     userkind = item.userkind;
    //                                 }
    //                                 ele.userkind = userkind;
    //                                 ele.pwd = ele.pwd == "" ? "" : ele.pwd;
    //                                 let hiscode1 = "";
    //                                 if (item.hiscode1 == "" || item.hiscode1 == null) {
    //                                     hiscode1 = item.userno;
    //                                 } else {
    //                                     hiscode1 = item.hiscode1;
    //                                 }
    //                                 ele.hiscode1 = hiscode1;

    //                                 let doctorkind = "";
    //                                 if (item.doctorkind == "" || item.doctorkind == null) {
    //                                     if (ele.doctorkind == "" || ele.doctorkind == null) {
    //                                         doctorkind = "";
    //                                     } else {
    //                                         doctorkind = ele.doctorkind;
    //                                     }
    //                                 } else {
    //                                     doctorkind = item.doctorkind;
    //                                 }
    //                                 ele.doctorkind = doctorkind;

    //                                 let doctormaster = "";
    //                                 if (item.doctormaster == "" || item.doctormaster == null) {
    //                                     if (ele.doctormaster == "" || ele.doctormaster == null) {
    //                                         doctormaster = "0";
    //                                     } else {
    //                                         doctormaster = ele.doctormaster;
    //                                     }
    //                                 } else {
    //                                     doctormaster = item.doctormaster;
    //                                 }
    //                                 ele.doctormaster = doctormaster;
    //                                 let hiscode2 = "";
    //                                 if (item.hiscode2 == "" || item.hiscode2 == null) {
    //                                     if (ele.hiscode2 == "" || ele.hiscode2 == null) {
    //                                         hiscode2 = "";
    //                                     } else {
    //                                         hiscode2 = ele.hiscode2;
    //                                     }
    //                                 } else {
    //                                     hiscode2 = item.hiscode2;
    //                                 }
    //                                 ele.hiscode2 = hiscode2;

    //                                 let deptno = "";
    //                                 if (item.deptno == "" || item.deptno == null) {
    //                                     if (ele.deptno == "" || ele.deptno == null) {
    //                                         deptno = "";
    //                                     } else {
    //                                         deptno = ele.deptno;
    //                                     }
    //                                 } else {
    //                                     deptno = item.deptno;
    //                                 }
    //                                 ele.deptno = deptno;

    //                                 let hospcode = "";
    //                                 if (ele.hospcode == "" || ele.hospcode == null) {
    //                                     if (item.hospcode == "" || item.hospcode == null) {
    //                                         hospcode = "All";
    //                                     } else {
    //                                         hospcode = item.hospcode;
    //                                     }
    //                                 } else {
    //                                     hospcode = ele.hospcode;
    //                                 }
    //                                 ele.hospcode = hospcode;
    //                                 let hospname = this.hospOption.find((m) => m.value == hospcode);
    //                                 if (hospname != undefined) {
    //                                     hospname = hospname.label;
    //                                 } else {
    //                                     hospname = "无效医院";
    //                                 }
    //                                 ele.hospitalname = hospname;
    //                                 let idcardno = "";
    //                                 if (ele.idcardno == "" || ele.idcardno == null) {
    //                                     if (item.idcardno == "" || item.idcardno == null) {
    //                                         idcardno = "";
    //                                     } else {
    //                                         idcardno = item.idcardno;
    //                                     }
    //                                 } else {
    //                                     idcardno = ele.idcardno;
    //                                 }
    //                                 ele.idcardno = idcardno;
    //                                 let wardno = "";
    //                                 if (ele.wardno == "" || ele.wardno == null) {
    //                                     if (item.wardno == "" || item.wardno == null) {
    //                                         wardno = "";
    //                                     } else {
    //                                         wardno = item.wardno;
    //                                     }
    //                                 } else {
    //                                     wardno = ele.wardno;
    //                                 }
    //                                 ele.wardno = wardno;
    //                                 let isenabled = "1";
    //                                 if (ele.enabled == "" || ele.enabled == null) {
    //                                     if (item.enabled == "" || item.enabled == null) {
    //                                         isenabled = "1";
    //                                     } else {
    //                                         isenabled = item.enabled;
    //                                     }
    //                                     isenabled = "1";
    //                                 } else {
    //                                     isenabled = ele.enabled;
    //                                 }
    //                                 ele.enabled = isenabled;
    //                                 ele.inputcode = item.inputcode;

    //                                 throw Error();
    //                             }
    //                         });
    //                     } catch (e) {}
    //                 } else {
    //                     let hospcode = item.hospcode == null ? "All" : item.hospcode;
    //                     let hospname = this.hospOption.find((m) => m.value == hospcode);
    //                     if (hospname != undefined) {
    //                         hospname = hospname.label;
    //                     } else {
    //                         hospname = "无效医院";
    //                     }
    //                     let initialdata = {
    //                         userno: item.userno,
    //                         username: item.username,
    //                         userkind: item.userkind,
    //                         pwd: "",
    //                         hiscode1: item.hiscode1 == null ? item.userno : item.hiscode1,
    //                         doctorkind: item.doctorkind,
    //                         doctormaster: item.doctormaster == null ? "0" : item.doctormaster,
    //                         hiscode2: item.hiscode2,
    //                         deptno: item.deptno,
    //                         hospcode: hospcode,
    //                         hospitalname: hospname,
    //                         idcardno: item.idcardno,
    //                         wardno: item.wardno,
    //                         enabled: item.enabled == null ? "1" : item.enabled,
    //                         inputcode: item.inputcode,
    //                         utype: "U",
    //                         syncflag: item.syncflag,
    //                     };
    //                     this.$refs.Main_Table.insert(initialdata);
    //                 }
    //             });
    //             this.MainLoading = false;
    //             this.$message({
    //                 type: "warining",
    //                 message: "用户管理数据同步完成！",
    //             });
    //             this.usersync = false;
    //         })
    //         .catch((e) => {
    //             console.log("error", e);
    //             this.MainLoading = false;
    //         });
    // },
    // savesyncdata() {
    //     this.MainLoading = true;
    //     this.$tool
    //         .request({
    //             url: "MNG/MNG1/MNG110",
    //             method: "post",
    //             data: {
    //                 action: "savesyncdata",
    //                 syncinfo: this.$refs.Main_Table.getRecordset(),
    //             },
    //         })
    //         .then((response) => {
    //             if (response.errcode == "1") {
    //                 this.$message({
    //                     type: "success",
    //                     message: "保存成功！",
    //                 });
    //                 this.usersync = true;
    //                 this.MainTable_Rfresh();
    //             } else {
    //                 this.$message({
    //                     type: "error",
    //                     message: "保存失败！" + response.errmsg,
    //                 });
    //                 this.usersync = false;
    //             }

    //             this.MainLoading = false;
    //         })
    //         .catch((e) => {
    //             console.log("error", e);
    //             this.MainLoading = false;
    //         });
    // },
    //对应角色左边双击
    tab_dyjs_nohavenuser_dbclickEvent({ row, rowIndex, column, columnIndex }, event) {
      if (this.ifCanEditFlag && this.$tool.getSession(this.$tool.loginuserno).toUpperCase() != "ADMIN") {
        this.$message({
          type: "warning",
          message: "医院代码All不可修改！",
        });
        return false;
      }
      let _this = this;
      this.$tool
        .request({
          url: "MNG/MNG1/MNG110",
          method: "post",
          data: {
            action: "secsysrole_save",
            userno: _this.userno,
            del_roleno: "",
            add_roleno: row.roleno,
          },
        })
        .then((res) => {
          _this.getRoleInfo();
        })
        .catch((e) => {
          _this.$message.error(e);
        });
    }, //对应角色右边双击
    tab_dyjs_havenuser_dbclickEvent({ row, rowIndex, column, columnIndex }, event) {
      if (this.ifCanEditFlag && this.$tool.getSession(this.$tool.loginuserno).toUpperCase() != "ADMIN") {
        this.$message({
          type: "warning",
          message: "医院代码All不可修改！",
        });
        return false;
      }
      let _this = this;
      this.$tool
        .request({
          url: "MNG/MNG1/MNG110",
          method: "post",
          data: {
            action: "secsysrole_save",
            userno: _this.userno,
            del_roleno: row.roleno,
            add_roleno: "",
          },
        })
        .then((res) => {
          _this.getRoleInfo();
        })
        .catch((e) => {
          _this.$message.error(e);
        });
    }, //对应院区左边双击
    tab_dyyq_nohavenhosp_dbclickEvent({ row, rowIndex, column, columnIndex }, event) {
      if (this.ifCanEditFlag && this.$tool.getSession(this.$tool.loginuserno).toUpperCase() != "ADMIN") {
        this.$message({
          type: "warning",
          message: "医院代码All不可修改！",
        });
        return false;
      }
      let _this = this;
      this.$tool
        .request({
          url: "MNG/MNG1/MNG110",
          method: "post",
          data: {
            action: "secuserhosp_save",
            userno: _this.userno,
            del_hospcode: "",
            add_hospcode: row.hospcode,
            seq: row.seq,
          },
        })
        .then((res) => {
          _this.getHospInfo();
        })
        .catch((e) => {
          _this.$message.error(e);
        });
    }, //对应院区右边双击
    tab_dyyq_havenhosp_dbclickEvent({ row, rowIndex, column, columnIndex }, event) {
      if (this.ifCanEditFlag && this.$tool.getSession(this.$tool.loginuserno).toUpperCase() != "ADMIN") {
        this.$message({
          type: "warning",
          message: "医院代码All不可修改！",
        });
        return false;
      }
      let _this = this;
      this.$tool
        .request({
          url: "MNG/MNG1/MNG110",
          method: "post",
          data: {
            action: "secuserhosp_save",
            userno: _this.userno,
            del_hospcode: row.hospcode,
            add_hospcode: "",
            seq: row.seq,
          },
        })
        .then((res) => {
          _this.getHospInfo();
        })
        .catch((e) => {
          _this.$message.error(e);
        });
    },
    //对应区域左边双击
    tab_dyyq_nohavenreg_dbclickEvent({ row, rowIndex, column, columnIndex }, event) {
      if (this.ifCanEditFlag && this.$tool.getSession(this.$tool.loginuserno).toUpperCase() != "ADMIN") {
        this.$message({
          type: "warning",
          message: "医院代码All不可修改！",
        });
        return false;
      }
      let _this = this;
      this.$tool
        .request({
          url: "MNG/MNG1/MNG110",
          method: "post",
          data: {
            action: "secuserreg_save",
            userno: _this.userno,
            del_regionid: "",
            add_regionid: row.regionid,
            seq: row.seq,
          },
        })
        .then((res) => {
          _this.getRegInfo();
        })
        .catch((e) => {
          _this.$message.error(e);
        });
    }, //对应区域右边双击
    tab_dyyq_havenreg_dbclickEvent({ row, rowIndex, column, columnIndex }, event) {
      if (this.ifCanEditFlag && this.$tool.getSession(this.$tool.loginuserno).toUpperCase() != "ADMIN") {
        this.$message({
          type: "warning",
          message: "医院代码All不可修改！",
        });
        return false;
      }
      let _this = this;
      this.$tool
        .request({
          url: "MNG/MNG1/MNG110",
          method: "post",
          data: {
            action: "secuserreg_save",
            userno: _this.userno,
            del_regionid: row.regionid,
            add_regionid: "",
            seq: row.seq,
          },
        })
        .then((res) => {
          _this.getRegInfo();
        })
        .catch((e) => {
          _this.$message.error(e);
        });
    }, //用户名称改变自动生成拼音码
    usernamechange_event() {
      this.Tab_jbxx_Data.inputcode = this.$pub.CreateInputcode(this.Tab_jbxx_Data.username, this, 16);
    }, //检查用户代号是否重复
    usernochange_event() {
      let _this = this;
      this.$tool
        .request({
          url: "MNG/MNG1/MNG110",
          method: "post",
          data: {
            action: "userno_validation",
            userno: _this.Tab_jbxx_Data.userno,
          },
        })
        .then((res) => {
          if (res != "1") {
            _this.$message.error("用户代号不可重复！");
            _this.Tab_jbxx_Data.userno = "";
          }
        })
        .catch((e) => {
          _this.$message.error(e);
        });
    }, //检查form表单是否改变
    HasChange() {
      this.changeflag = true;
    }, //区域LIS模式下医院改变查询
    hospitalChange(code, name) {
      this.hospitalval = code;
      this.MainTable_Rfresh();
    },
    //顶部查询
    deptchange(code, name) {
      this.deptno = code;
      this.MainTable_Rfresh();
    },
    //表单科室修改
    deptnoChange(code, name) {
      this.Tab_jbxx_Data.deptno = code;
      this.HasChange();
    },
    //表单病区修改
    wardnoChange(code, name) {
      this.Tab_jbxx_Data.wardno = code;
      this.HasChange();
    }, //hiscode1对照医生字典 
    hiscode1Open() {
      this.hiscode1Dialog = true;
      this.hiscode1Dialogkey++;
    },
    //hiscode1对照医生字典 
    SelectDoctor(code, name) {
      this.Tab_jbxx_Data.hiscode1 = code;
      this.hiscode1Dialog = false;
      this.HasChange();
    },
    // 批量导出签名
    BtndownloadSign() {
      let _this = this;
      let p = { prgno: "MNG110" };
      _this.$pub.commexport(_this, p, "用户签名导出" + ".zip");
    },
    BacthUploadSign() {
      this.fileimportform.fileList = [];
      this.batchuoloaddialog = true;
    },
    //立即上传
    uploadFile() {
      if (this.fileimportform.fileList.length > 0) {
        console.log("this.fileimportform.fileList", this.fileimportform.fileList);
        this.batchuoloaddialog = false;
        this.totalcount = this.fileimportform.fileList.length;
        this.finishcount = 0;
        this.failcount = 0;
        this.successcount = 0;
        this.importfileindex = 0;
        this.BatImportTableData = [];
        this.failname = "";
        this.ImportFile(this.fileimportform.fileList[this.importfileindex].raw);
      } else {
        this.$alert("请先选择文件再上传！");
        this.batchuoloaddialog = true;
      }
    },
    ImportFile(file) {
      var URL = this.$tool.baseUrl.replace("api", "z") + "fileupload";
      let formData = new FormData();
      // 将上传的文件放到数据对象中
      formData.append("file", file);
      formData.append("action", "MNG110");
      axios
        .post(URL, formData, { "Content-Type": "multipart/form-data" })
        .then((res) => {
          if (res.status == 200 && res.data.flag == "1") this.successcount++;
          else {
            this.failcount++;
            this.failname = this.failname + file.name + ";";
          }
          if (++this.importfileindex < this.totalcount) {
            this.ImportFile(this.fileimportform.fileList[this.importfileindex].raw);
          } else {
            if (this.failcount > 0) {
              const h = this.$createElement;
              var msgall = "成功上传" + this.successcount + "个电子签名";
              var msgfial = "失败" + this.failcount + "个：" + this.failname;
              this.$confirm("提示", { title: "提示", message: h("div", [h("p", msgall), h("p", msgfial)]), confirmButtonText: "确定", cancelButtonText: "取消", showCancelButton: false, type: "warning" });
            } else {
              this.$message({
                message: "成功上传" + this.totalcount + "个电子签名！",
                type: "success",
              });
            }
            this.fileimportform.fileList = [];
          }
        })
        .catch((e) => {
          console.log("error", e);
        });
      this.finishcount++;
    },
    // 上传文件之前的钩子, 参数为上传的文件,若返回 false 或者返回 Promise 且被 reject，则停止上传
    beforeUploadFile(file) {
      let extension = file.name.substring(file.name.lastIndexOf(".") + 1);
      let islt2M = file.size / 1024 / 1024 < 2;
      let str = ",jpg,jpeg,png,";
      const isjpg = str.indexOf("," + extension + ",") == -1;

      if (str.indexOf("," + extension + ",") == -1) {
        this.$message({
          type: "warning",
          message: `仅支持【jpg, jpeg, png】格式，且不超过2M`,
        });
      }
      if (!islt2M) {
        this.$message({
          type: "warning",
          message: `签名图片大小不得超过2M`,
        });
      }
      return !isjpg && islt2M;
    },
    // 删除之前钩子
    handleFileRemove(file, fileList) {
      this.fileimportform.fileList = fileList;
    },
    // 文件状态改变时的钩子
    fileChange(file, fileList) {
      let extension = file.name.substring(file.name.lastIndexOf(".") + 1);
      let islt2M = file.size / 1024 / 1024 < 2;
      let str = ",jpg,jpeg,png,";
      const isjpg = str.indexOf("," + extension + ",") == -1;

      if (str.indexOf("," + extension + ",") == -1) {
        this.$message({
          type: "error",
          message: `仅支持【jpg, jpeg, png】格式，且不超过2M`,
        });
      }
      if (!islt2M) {
        this.$message({
          type: "error",
          message: `签名图片大小不得超过2M`,
        });
      }
      if (isjpg || !islt2M) {
        let index = fileList.indexOf(file);
        fileList = fileList.splice(index);
      }
      if (!isjpg && islt2M) {
        this.fileimportform.fileList = fileList;
      }
    },
    // 文件超出个数限制时的钩子
    exceedFile(files, fileList) {
      this.$notify.warning({
        title: "警告",
        message: `只能选择 ${this.limitNum} 个文件，当前共选择了 ${files.length + fileList.length} 个`,
      });
    },
    //获取IP地址范围列表
    async getIpList() {
      try {
        if (!this.userno) {
          this.useripList = [];
        } else {
          const res = await this.$tool.request({
            url: "MNG/MNG1/MNG110",
            method: "post",
            data: {
              action: "get_secuseriplist",
              userno: this.userno,
            },
          });
          this.useripList = res.data;
        }
      } catch (e) {
        this.$alert(e, "提示", {
          confirmButtonText: "确定",
        });
      }
    },
    btnDetailAdd() {
      let insertRow = {
        userno: this.userno,
      };
      this.$refs.ipTable
        .insert({
          ...insertRow,
        })
        .then(({ row }) => {
          this.$nextTick(() => {
            this.$refs.ipTable.setCurrentRow(row);
          });
        });
      this.HasChange();
    },
    btnDetailDel() {
      var delrow = this.$refs.ipTable.getCurrentRow();
      var havedata = this.$refs.ipTable.getTableData().fullData;
      if (delrow && havedata.length > 0) {
        var rowindex = havedata.indexOf(delrow);
        if (havedata.length > 0) {
          this.$refs.ipTable.remove(delrow);
          if (rowindex == havedata.length - 1) rowindex--;
          let selectrow = this.$refs.ipTable.getTableData().fullData[rowindex];
          this.$refs.ipTable.setCurrentRow(selectrow);
        }
        this.HasChange();
      } else {
        this.$message.warning("请先选中要删除的明细！");
      }
    },
    //做多选
    SetMultipleSelect() {
      if (this.ifCanEditFlag && this.$tool.getSession(this.$tool.loginuserno).toUpperCase() != "ADMIN") {
        this.$message({
          type: "warning",
          message: "医院代码All不可修改！",
        });
        return false;
      }
      var rows = this.$refs.tab_dyyq_nohaven_table.getSelectRecords();
      var hospcodes = "";
      if (rows.length > 0) {
        for (let index = 0; index < rows.length; index++) {
          hospcodes += rows[index].hospcode + ",";
        }
        hospcodes = hospcodes.substring(0, hospcodes.length - 1);
      }
      let _this = this;
      this.$tool
        .request({
          url: "MNG/MNG1/MNG110",
          method: "post",
          data: {
            action: "secuserhosp_save",
            userno: _this.userno,
            del_hospcode: "",
            add_hospcode: "",
            add_hospcodes: hospcodes,
            del_hospcodes: "",
          },
        })
        .then((res) => {
          _this.getHospInfo();
        })
        .catch((e) => {
          _this.$message.error(e);
        });
    },
    DelMultipleSelect() { },
    //修改密码功能
    pswmod() {
      this.pswObj = {
        userno: this.selrow.userno,
        username: this.selrow.username,
        pwsfirst: "", //密码
        pwssecond: "", //确认密码
        pswdialog: true,
      };
    },
    pswObjSave() {
      if (this.pswObj.pwsfirst != this.pswObj.pwssecond) {
        this.$alert("两次密码不一致，请检查后重试", "提示");
      } else {
        let pwd = md5("rms-" + this.pswObj.pwsfirst + "-rme");
        this.$tool
          .request({
            url: "MNG/MNG1/MNG110",
            method: "post",
            data: {
              action: "pswObjSave",
              pwd: pwd,
              userno: this.pswObj.userno,
            },
          })
          .then((res) => {
            if (res.errcode == "1") {
              this.$pub.message(this, "密码修改成功！", "success");
              this.pswObj.pswdialog = false;
            } else {
              this.$alert(res.errmsg, "提示");
            }
          })
          .catch((e) => {
            this.$message.error(e);
          });
      }
    },
    //增加同步电子签名
    syncsign() {
      this.MainLoading = true;
      this.$tool
        .request({
          url: "MNG/MNG1/MNG110",
          method: "post",
          timeout: 600000,
          data: {
            action: "syncsign",
          },
        })
        .then((res) => {
          this.$alert(res.errmsg, "提示");
          this.MainLoading = false;
        })
        .catch((e) => {
          this.MainLoading = false;
          this.$message.error(e.message);
        });
    },
    resetLogindt() {
      if (this.userno == "") {
        this.$message.error("请先选择用户！");
        return false;
      }
      this.$confirm("是否重置该用户的登录时间?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.$tool
            .request({
              url: "MNG/MNG1/MNG110",
              method: "post",
              data: {
                action: "secsysuser_resetlogindt",
                userno: this.userno,
              },
            })
            .then((res) => {
              if (res.errcode == "1") {
                this.$message({
                  message: "重置成功！",
                  type: "success",
                });
              } else {
                this.$message.error("重置失败！" + res.errmsg);
              }
            })
            .catch((e) => {
              this.$message.error(e);
            });
        })
        .catch(() => {
        });
    },
  },
};
</script>

<style scoped>
.addBtn {
  position: absolute;
  bottom: 1%;
  left: 5%;
  z-index: 999;
  display: flex;
}
::v-deep.vxe-body--row.row-stop {
  color: white !important;
  background-color: rgb(255, 192, 192) !important;
}

::v-deep tr.vxe-body--row.row-new {
  color: #cc6600;
}

::v-deep tr.vxe-body--row.row-modify {
  color: blue !important;
}

/* ::v-deep.vxe-body--row.row-green {
  background-color: #187 !important;
  color: #fff;
} */
::v-deep.vxe-body--column.col-red {
  background-color: red;
  color: #fff;
}

::v-deep.el-checkbox__inner::after {
  border: 2px solid #000000 !important;
  box-sizing: content-box;
  content: "";
  border-left: 0 !important;
  border-top: 0 !important;
  height: 7px;
  left: 4px;
  position: absolute;
  top: 1px;
  transform: rotate(45deg) scaleY(0);
  width: 3px;
  transition: transform 0.15s ease-in 0.05s;
  transform-origin: center;
}

::v-deep.el-checkbox__input.is-disabled+span.el-checkbox__label {
  color: #000000;
  cursor: not-allowed;
}

::v-deep .el-checkbox__input.is-disabled .el-checkbox__inner,
.el-checkbox__input.is-disabled.is-checked .el-checkbox__inner+.el-input.is-disabled .el-input__inner {
  background-color: #ffffff !important;
}

::v-deep .el-upload-list--picture {
  width: 350px;
}

::v-deep .el-upload-dragger {
  width: 300px;
  height: 130px;
}

.table-deal-btn {
  text-align: center;
  margin-left: 5px;
  margin-right: 5px;
  margin-top: auto;
  margin-bottom: auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.table-deal-btn-item div {
  margin: 5px 0;
}

.pagetop {
  left: 0;
  right: 0;
  height: 72px;
  display: -webkit-box;
  -webkit-box-pack: center;
  -webkit-box-align: center;
  border: solid 1px #ccc;
  position: absolute;
  z-index: 99;
}

.pagecenter {
  position: absolute;
  top: 76px;
  width: 100%;
  left: 0;
  bottom: 0px;
  overflow: auto;
}

.middle-center {
  position: absolute;
  height: 100%;
  right: 575px;
  left: 0;
  overflow: auto;
}

.middle-right {
  position: absolute;
  top: 0;
  bottom: 0px;
  overflow: visible;
  width: 570px;
  right: 0px;
}

table tr td:nth-child(odd) {
  text-align: right;
  white-space: nowrap;
}

table tr td:nth-child(even) {
  text-align: left;
}

/* table tr td:nth-child(1) {
  width: 80px;
} */
table {
  font-size: 12px;
  border-collapse: separate;
  border-spacing: 5px;
}

.table1style tr td {
  padding: 0px 2px 0px 5px;
}

.avatar-uploader .el-upload {
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.avatar-uploader .el-upload:hover {
  border-color: #409eff;
}

.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 178px;
  height: 178px;
  line-height: 178px;
  text-align: center;
}

.avatar {
  width: 178px;
  height: 178px;
  display: block;
}

.avatar-uploader-icon1 {
  font-size: 28px;
  color: #8c939d;
  width: 178px;
  height: 50px;
  line-height: 50px;
  text-align: center;
}

.avatar1 {
  width: 178px;
  height: 50px;
  display: block;
}

.middle-tab-top {
  position: absolute;
  top: 0px;
  width: 100%;
  height: 37px;
}

.middle-bottom {
  position: absolute;
  top: 37px;
  width: 100%;
  bottom: 0px;
  overflow: auto;
}

.middle-tab-bottom {
  position: absolute;
  top: 0px;
  width: 100%;
  bottom: 0px;
  overflow: auto;
  max-height: calc(100% - 50px);
}

::v-deep .el-button.is-disabled {
  border: 0px;
  color: grey;
  background-color: #e6e6e6;
  font-weight: normal;
}

::v-deep tr.vxe-body--row.row--current {
  color: #000000;
  font-weight: bold;
}

::v-deep.pwdtable table tr td {
  text-align: left;
  white-space: nowrap;
  padding: 5px;
}</style>